Regular expression help...

  • Thread starter Thread starter almurph
  • Start date Start date
A

almurph

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.
 
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
 
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...
 
Hi,

<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.
 
Back
Top