Regular Expressions basic question

Discussion in 'JavaScript' started by maximusdm, Mar 31, 2010.

  1. #1
    how can I test if a user typed a number or a boolean value using RegEx?

    The number can be ANY number;
    The boolean value should be 'true' or 'false' (lowercase);
    Also need a sample for boolean value 'true' or 'false' (lowercase OR uppercase);

    Thank you so much!
    M
     
    maximusdm, Mar 31, 2010 IP
  2. maximusdm

    maximusdm Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Anyone? :(
     
    maximusdm, Apr 6, 2010 IP
  3. unigogo

    unigogo Peon

    Messages:
    286
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    For number, use

    /\d+/g

    Regular expression must be used on string and cannot be used on boolean value.
     
    unigogo, Apr 9, 2010 IP
  4. maximusdm

    maximusdm Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I found this /^(\d|-)?(\d|,)*\.?\d*$/ for using with numbers.

    Thanks
     
    maximusdm, Apr 12, 2010 IP