Need help on Regular expression in Java Script [Resolved]

Posted by Riyazhaider under JavaScript on 1/9/2014 | Points: 10 | Views : 719 | Status : [Member] | Replies : 2
i need a regular expression that except 0-3 digit seprated by / five time

exp. 2/23/21/222/12




Responses

Posted by: kgovindarao523-21772 on: 1/9/2014 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
Hi,

Here is the pattern:

<script type="text/javascript">
function myfunction()
{
var str = '2/23/21/222/12';
var patt = new RegExp("[0-9]+(\/[0-9]+){0,4} ", "i");
if(patt.test(str))
alert('Pattern Matched');
else
alert('Pattern UnMatched');
}
</script>


Thank you,
Govind

Riyazhaider, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/9/2014 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
Hi,

Ignore Last one.
Here is the exact code
<script type="text/javascript">

function myfunction()
{

var str = '2/23/21/222/12';
var patt = new RegExp("^[0-9]{1,3}\/[0-9]{1,3}\/[0-9]{1,3}\/[0-9]{1,3}\/[0-9]{1,3}$", "i");
if(patt.test(str))
alert('Pattern Matched');
else
alert('Pattern UnMatched');
}
</script>


Thank you,
Govind

Riyazhaider, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response