Simple Regular Expressions Question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm trying to use preg_match to isolate a line of text in a webpage that  
has city, state, country.

What I want to do is use preg_match to find that line, which can be in  
different places.  I am trying to strip some data from some webpages that I  
have.  So I'm writing a PHP script to do it.

I was hoping to do a preg_match that could find a variable number of  
letters followed by a comma, follwed by a space, followed by another  
variable number of letters, followed by a comma.  Then I know I have the  
line I'm looking for.

Any suggestions?

Re: Simple Regular Expressions Question

How far have you got?

Re: Simple Regular Expressions Question

Quoted text here. Click to load it

I think I may have got it.

'/([A-Z a-z]+,\s+[A-Z a-z]+,\s+[A-Z a-z])/'

It seems to work pretty well, though not perfectly.  If you have any  
comments or improvements, please let me know.


Site Timeline