View Full Version : RegEx-how to check that dot occure more then once in string?
val75
Dec 30th 2008, 4:07 am
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
phper
Jan 1st 2009, 3:24 pm
/\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.
rohan_shenoy
Jan 2nd 2009, 9:41 am
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
}
val75
Jan 3rd 2009, 3:15 pm
You're Great.
That's preaty cleaver.
Thanx man.
val75
Jan 3rd 2009, 3:19 pm
Thanx a lot .-)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.