Forum Moderators: coopster

Message Too Old, No Replies

what is the correct pattern for this

pattern

         

cody7

3:59 am on Apr 7, 2005 (gmt 0)

10+ Year Member



i have here my phone_number.txtthat contains

(111)-111-1111
222-222-2222
333-3333

i'm using preg_match_all() for my script

preg_match_all('/([0-9]{3,})(-)[0-9]{4,}/',$mainHtml,$mainCode);

do not mind $mainHtml and $mainCode

my question is.... if i apply this kind of patter ( '/([0-9]{3,})(-)[0-9]{4,}/' ) in my preg_match_all()my matches would be

111-1111
222-2222
333-3333

What is the correct pattern for my function to achive this kind of result only.


333-3333

Thank you for any help...

ironik

5:13 am on Apr 7, 2005 (gmt 0)

10+ Year Member



Your pattern should probably be:

/([0-9]{3})(-[0-9]{3,4}){1,2}/'

That should match all of your phone numbers in your example text file.