# Extracting a number from a long number

Page 1 of 1

## 1 Replies - 690 Views - Last Post: 17 February 2009 - 02:44 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=87295&amp;s=74c393e9d3450f0c7abc9bd29a8ad9c2&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 nick898

• New D.I.C Head

Reputation: 0
• Posts: 9
• Joined: 17-February 09

# Extracting a number from a long number

Posted 17 February 2009 - 01:57 PM

Hi!

I was wondering how it could be possible to extract a certain number within a long number sequence. For example I ask the user for a telephone number and I'd like to then extract the area code from it without the rest of the numbers.

Thanks!

Is This A Good Question/Topic? 0

## Replies To: Extracting a number from a long number

### #2 horace

• D.I.C Lover

Reputation: 652
• Posts: 3,368
• Joined: 25-October 06

## Re: Extracting a number from a long number

Posted 17 February 2009 - 02:44 PM

nick898, on 17 Feb, 2009 - 07:57 PM, said:

Hi!

I was wondering how it could be possible to extract a certain number within a long number sequence. For example I ask the user for a telephone number and I'd like to then extract the area code from it without the rest of the numbers.

Thanks!

you could read the number as a String and then use the method substring() to extract the area code
http://java.sun.com/.../java...ing(int,%20int)
Was This Post Helpful? 0

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}