# Extracting a number from a long number

Page 1 of 1

## 1 Replies - 602 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=0e718c27beefab5bae668a51935ea5ca&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 nick898

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: 342
• Posts: 2,121
• 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)