Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I extract only mobile numbers from my text file? Mobile numbers format is 03xx-xxxxxxx.

Text is something like this:

1 Mr.Pervaiz Ahmad Latifi Rajput Traders, W/571, Ratta Road, Near Novalty Cinema, Rawalpindi Tel:5774972,5775283,0300-5358177 Fax # E-mail: www. -

2 Mr.Ashraf Raza Khan Imran Aluminium Works, Shop # 06, 73-A, Usman Pura, Rawalpindi Tel:0300-9544837 Fax # E-mail: www. -

I need to extract mobile numbers and list them one by one in a new line. For example:

03005358177
03009544837
03xxxxxxxxx
03xxxxxxxxx

Please let me know all steps accordingly as I know nothing. I really appreciate your quick & kind help!

share|improve this question

closed as unclear what you're asking by Mokubai, Scott, mpy, ncdownpat, Dave M Nov 7 '13 at 19:05

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
A regular expression to match phone numbers is very common there are also hundreds of examples. What have you tried? –  Ramhound Sep 27 '13 at 12:46
    
I don't know regex neither worked in excel :( –  Farhan Ali Sep 27 '13 at 12:48
1  
If you'd like to do this in Excel, edit your question to say so specifically. (You say "text file", which is a very different thing). There might be an excel search that'll do it for you (I wouldn't know). –  alexis Sep 27 '13 at 12:50
    
@user257912 - You said nothing about Excel in your question. Your question isn't clear and is likely to be closed at this rate. I am pretty sure VBS ( Visual Basic Script ) supports Regular Expressions thus Excel should be able to do this. –  Ramhound Sep 27 '13 at 12:53

1 Answer 1

Welcome to superuser.sx. Be aware that this site is for people who'll do a little work themselves-- It's not a good fit for questions about which you "know nothing".

You can do what you're looking for with "regular expressions". For example, you can match numbers of the form 03xx-xxxxxxx with the regular expression /\b03\d\d-\d{7}\b/.

Many programming and scripting languages include regular expressions, and there are even websites where you can upload a text file and experiment with searching it. Check them out and come back when you have more specific questions.

share|improve this answer
    
thanks anyways! –  Farhan Ali Sep 27 '13 at 12:51
    
Finally, I have found the way & extracted mobile numbers from text doc. Now, they are formatted one by one in a new line. for example: 03008565710 03335214569 0922563141 0515792424 But I want to delete the number lines which are not starting with 03xxXXXXXXX ? –  Farhan Ali Sep 27 '13 at 14:22
    
If you are on Linux or OS X, use egrep '^03' numbers.txt > mobiles.txt. If you're on Windows, clarify that in your question or download one of the many grep-lookalikes (e.g., grepWin might be able to do it). And read up on regular expressions, they have many uses. –  alexis Sep 30 '13 at 20:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.