This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes un-format a phone number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "un-format a phone number" Watch "un-format a phone number" New topic
Author

un-format a phone number

Marie Mazerolle
Ranch Hand

Joined: Oct 01, 2002
Posts: 81
Hi,
Phone numbers are displayed in my app as (555) 555-6676. I figured out how to use regular expressions to verify if it's in the correct format, but now I have to save the phone numbers as 5555556676 in the database.
What would be the best way to strip the extra characters from my string? I tried myPhoneString.replace( '(', '' );
but it will not accept empty character literals...
Thanks,
Marie
Marie Mazerolle
Ranch Hand

Joined: Oct 01, 2002
Posts: 81
oops, I just found out that I can also use regexp to remove the offending characters.
Marie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: un-format a phone number
 
It's not a secret anymore!