phplists wrote:
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.
Well, it depends what "usually is" (can be) before what you want to get
and the regex family your using. If it's PCRE, you may try something
like "\b\d{4} [A-Za-zÅØ]{2,20}" \b = "word boundary", it's basically
a word separator and it's not included in the result you get (since it's
more a "position" rather than a "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 think it is. IIRC what you define in a "class" (i.e. between
square-brackets) is quite fast; e.g. "[ab]" fastest than "(a|b)", is
that what you were asking?
--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
rsalazar@xxxxxxxxxxxx
http://www.innox.com.mx
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php