1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

RegEx-how to check that dot occure more then once in string?

Discussion in 'JavaScript' started by val75, Dec 30, 2008.

  1. #1
    Hi.
    I wrote pattern "var patt3=/\d\.\./;" so I can check double dot occure in string.
    But how to find "1.11111.1" that dot occure more then once in string?
    Thanx
     
    val75, Dec 30, 2008 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    /\d\.\d*\./

    - Change '*' to '+' if you don't want to match two consecutive dots
    - Change '\d' to '.' if you want to match any character rather than just digits.
     
    phper, Jan 1, 2009 IP
  3. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #3
    
    var string="abc.123.xyz";
    var array=string.split(".");
    var length=array.length;
    if(length==2)
       {
       //dot occurs ONCE
       }
    else
       {
       //0 or more than 1 time
       }
    
    Code (JAVASCRIPT):
     
    rohan_shenoy, Jan 2, 2009 IP
  4. val75

    val75 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You're Great.
    That's preaty cleaver.
    Thanx man.
     
    val75, Jan 3, 2009 IP
  5. val75

    val75 Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanx a lot .-)
     
    val75, Jan 3, 2009 IP