Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
basic
035stringmethods_match.js
035stringmethods_match.js
/** * Sting methods: match * i flag means case insensitive matching * g flag means global (all occurencies, not only the first) */ var str, x, xi, xg, xig; str = "SOME simple Sample string"; x = str.match(/s\wm/); //case sensitive xi = str.match(/s\wm/i); //case insensitive xg = str.match(/s\wm/g); //global xig = str.match(/s\wm/ig); //ignored and global console.log(x); // [ 'sim', index: 5, input: 'SOME simple Sample string' ] console.log(xi); // [ 'SOM', index: 0, input: 'SOME simple Sample string' ] console.log(xg); // [ 'sim' ] console.log(xig); // [ 'SOM', 'sim', 'Sam' ]
Reload page
Preview
W3C validation
Edit Code
JS Console