I tried searching stackoverflow for various combination but some or other thing stops working.
I am new to REGEX.
My input is <abc.1.1.1 or abc.1.1 or abc.1 -->
case insensitive digits can be between 1-9 positive
var pattern= /[a-zA-Z].[1-9].[1-9].[1-9]$/;
the above pattern still accepts abc.a1.b.1
I am trying for following patterns
abc.1.1.1
or
abc.1.1
or
abc.1
Any help would be appreciated
You should use literal .
as just .
means "any character" Also you could improve it a bit using global
and ignoreCase
flags. Also use anchors ^
and $
var pattern= /^[a-z]+\.(([1-9]\.))+[1-9]$/ig;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments