Regular expression help...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • almurph@altavista.com

    #1

    Regular expression help...

    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.

  • Tim Ferguson

    #2
    Re: Regular expression help...

    "almurph@altavi sta.com" <almurph@altavi sta.com> wrote in
    news:1144247834 .657653.69760@i 39g2000cwa.goog legroups.com:
    [color=blue]
    > 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[/color]

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


    Tim F

    Comment

    • almurph@altavista.com

      #3
      Re: Regular expression help...

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

      Comment

      • Cerebrus

        #4
        Re: Regular expression help...

        Hi,
        [color=blue][color=green]
        >> If only I could test these[/color][/color]

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

        Comment

        Working...