

Task

   match a string against a regular expression
   substitute part of a string using a regular expression


/* 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);