Jump to content

JavaScript: Difference between revisions

No edit summary
 
Line 10: Line 10:
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions MDN Guide]
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions MDN Guide]
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
var myRegex = /(\d+),(\d+)/;
const myRegex = /(\d+),(\d+)/;
var myStr = "124,52";
const myStr = "124,52";
var match = myStr.match(myRegex);
const match = myStr.match(myRegex);
// Captures
// Captures
console.log(match[1], match[2]);
console.log(match[1], match[2]);