I want the regular expression for the data of type dd.d.dd.ddddd or
dd.d.d.ddddd
I want the regular expression for the data of type dd.d.dd.ddddd or
dd.d.d.ddddd,each d is for a digit between 0-9 and the regular expression
should represent both the formats. I am working in java script.I have
tried the following code.but it is not working for all the input strings.
<html>
<body>
<p id="demo">my string</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
//var regExp1=/[1-4]+\.[1-4]+\.[1-4]+\.[0-9]+$/;
var regExp1=/[1-4][1-4]\.[1-4]\.[1-4][1-4]\.[0-9][0-9][0-9][0-9][0-9]$/;
//var regExp1=/[0-9][0-9]\.[0-9]\.[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9]$/;
var str="Version of C:\hjkl.dll:14.6.17.90505 working File
Versn:18.1.9.17083,stopped file:13.1.14.25059 absjhdhgh";
var mystring=str.split(regExp1);
document.getElementById("demo").innerHTML=mystring;
}
</script>
</body>
</html>
Desired output is:
Version of C:\hjkl.dll:
working File Versn:
,stopped file:
absjhdhgh
No comments:
Post a Comment