Re: A quick Regex query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 4:57 PM -0500 2/16/06, phplists wrote:
Hi,

I am using the following:
[0-9]{4} [A-Za-zÅØ]{2,20}

to extract data like:
1000 Øslo

How can I alter the above to limit to ONLY 4 digits, or in other words exclude:
11000 Beograd

Please note that what I am extracting from is NOT at the begining of a line, so I can't use the ^ first.

How about:

  ^[^\d\r]*([0-9]{4} [A-Za-zÅØ]{2,20})

The backreferenced pattern $1 contains the extracted string.

Also, you may notice a couple of 'special' characters in my expression 'Å + Ø' By putting them in they seem to work fine, but is this the best way of doing it?

I'm sorry, I don't know the answer to that.

-Jim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux