RosettaCodeData/Task/Regular-expressions/Jsish/regular-expressions.jsish

11 lines
326 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
/* Regular expressions, in Jsish */
var re = /s[ai]mple/;
var sentence = 'This is a sample sentence';
var matches = sentence.match(re);
if (matches.length > 0) printf('%s found in "%s" using %q\n', matches[0], sentence, re);
var replaced = sentence.replace(re, "different");
printf("replaced sentence is: %s\n", replaced);