Home All Groups Group Topic Archive Search About

Regular expression help...

Author
5 Apr 2006 2:37 PM
almurph@altavista.com
Hi,

    Hope that you can help me here. What the regualr expression for:

any amount of non-digit characters follwed by some digits (and perhaps
a letter or 2 after this) - that is strings found in address numbers
especially in apartment numbers

like, for example:

#23
apt. 34
No.21A


    Any help on this much appreciated.

Thank you,
Al.

Author
5 Apr 2006 4:16 PM
Tim Ferguson
"almu***@altavista.com" <almu***@altavista.com> wrote in
news:1144247834.657653.69760@i39g2000cwa.googlegroups.com:

> any amount of non-digit characters follwed by some digits (and perhaps
> a letter or 2 after this) - that is strings found in address numbers
> especially in apartment numbers

  [^0-9]*[0-9]*[A-Za-z]{,2}


Tim F
Author
5 Apr 2006 4:41 PM
almurph@altavista.com
I tried my hand at this and here is what I came up with:

^\D+\d+[A-Za-z]?


If only I could test these...
Author
6 Apr 2006 2:10 AM
Cerebrus
Hi,

>> If only I could test these

<http://regexlib.com/RETester.aspx>

In my opinion, Regexes are only useful if you can very definitely
constrain the sample strings you might receive. Although the suggested
regexes might work (didn't test them), I would advise you to spare the
some thought to what anomalous address formats you might receive.

If the 3 examples you gave are the only possibilites, it would be good.
But as I read in good book sometime back : "All input is Evil !". In
other words, your users might enter text that you couldn't have
imagined in your wildest dreams. ;-)

Just my thoughts,

Regards,

Cerebrus.