regular expression help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kaeli

    regular expression help



    Hi guys,

    I need to do some validation and I am not that great at regular
    expressions.

    What would the regexp be for
    optional digit 1 or 2 followed by any digit followed by a dot followed
    by either a 1 or a 2 followed by one optional letter (M, C, L, or S) and
    one optional digit 1, 2, or 3 (letter may be followed by digit, but if
    no letter, only one digit)?

    That is, the following are valid:
    d.d
    d.dl
    d.dld (letter must be m,c,l,s and last d must be 1,2,or 3)
    dd.d (first d must be 1 or 2)
    dd.dl
    dd.dld

    Thanks for any help...

    -------------------------------------------------
    ~kaeli~
    All I ask for is the chance to prove that money
    cannot make me happy.


    -------------------------------------------------
  • Evertjan.

    #2
    Re: regular expression help

    kaeli <infinite.possi bilities@NOSPAM att.net> wrote in
    news:MPG.19e5f1 4dfa8f4feb98989 d@nntp.lucent.c om:
    [color=blue]
    > What would the regexp be for
    > optional digit 1 or 2 followed by any digit followed by a dot followed
    > by either a 1 or a 2 followed by one optional letter (M, C, L, or S) and
    > one optional digit 1, 2, or 3 (letter may be followed by digit, but if
    > no letter, only one digit)?
    >
    > That is, the following are valid:
    > d.d
    > d.dl
    > d.dld (letter must be m,c,l,s and last d must be 1,2,or 3)
    > dd.d (first d must be 1 or 2)
    > dd.dl
    > dd.dld
    >[/color]

    /[12]?\d\.[12]([mcls][123]?)?/i

    Comment

    • kaeli

      #3
      Re: regular expression help

      In article <Xns9408A9F15F8 78eejj99@194.10 9.133.29>, none@none.nl
      enlightened us with...[color=blue]
      >
      > /[12]?\d\.[12]([mcls][123]?)?/i
      >[/color]

      Thanks!
      --
      -------------------------------------------------
      ~kaeli~
      All I ask for is the chance to prove that money
      cannot make me happy.


      -------------------------------------------------

      Comment

      Working...