This is a discussion on need help for regex within the PHP Language forums, part of the PHP Programming Forums category; Hello folks, I want to retrieve full name, city name, state and country from following string: "(Firstname Lastname - Traverse ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello folks,
I want to retrieve full name, city name, state and country from following string: "(Firstname Lastname - Traverse City, MI United States)" I think maybe a regex can be a solution. However I don't have much knowledge on it. I need help. Thanks in advance! Alex Shi |
|
|||
|
Alex Shi wrote:
> I want to retrieve full name, city name, state and country from > following string: > "(Firstname Lastname - Traverse City, MI United States)" No more constraints? What does a state name look like, for example? preg_match( '`\((.*) - (.*), ([A-Z]{2}) ([^)]*)\)`sU', $string, $array); -- Jock |
|
|||
|
On 2004-03-07, Alex Shi <chpshi@stonix.com> wrote:
> Hello folks, > > I want to retrieve full name, city name, state and country from > following string: > "(Firstname Lastname - Traverse City, MI United States)" > > I think maybe a regex can be a solution. However I don't have > much knowledge on it. I need help. Thanks in advance! Have a look at http://be.php.net/manual/en/function.sscanf.php -- http://home.mysth.be/~timvw |