regular expression help

Discussion in 'Javascript' started by kaeli, Oct 2, 2003.

  1. kaeli

    kaeli Guest

    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.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
    -------------------------------------------------
     
    kaeli, Oct 2, 2003
    #1
    1. Advertisements

  2. kaeli

    Evertjan. Guest

    /[12]?\d\.[12]([mcls][123]?)?/i
     
    Evertjan., Oct 2, 2003
    #2
    1. Advertisements

  3. kaeli

    kaeli Guest

    kaeli, Oct 2, 2003
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.