Home of web learners

www.webn3rd.com

javascript has regular expression to make a search in string

Lets start with some code:

<html>
<head>
</head>
<body>
    <script>
var text = "Coding means learning";
         var regx = new RegExp( "means" );
         
         var result = regx.test(text);
         document.write(result); 
         
         
</script>       
</body>
</html>

output:

true

Here,we create a object regx,where we search for means,and by using test method under this variable regx,we input our variable text where we want to search

If the search string found in the text variable,then it return true

webn3rd.com

About webn3rd