

Task

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


var re=RegExp(".*string$");
re.matches("I am a string") //-->True
var s="I am a string thing"
re=RegExp("(string)")  // () means group, ie if you see it, save it
re.search(s,True) //-->True, .search(x,True) means search for a match, ie don't need .*
p,n:=re.matched[0] //.matched-->L(L(7,6),"string")
String(s[0,p],"FOO",s[p+n,*]) //-->"I am a FOO thing"
 
re.search(s,True); // using .matched clears it
m:=re.matched[1];
s.replace(m,"FOO"); // -->"I am a FOO thing"