

Task

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


with javascript_semantics
include builtins\regex.e
requires("1.0.2") -- (needs some recent bugfixes to regex.e for p2js)
string s = "I am a string"
printf(1,"\"%s\" %s with string\n",{s,iff(length(regex(`string$`,s))?"ends":"does not end")})
printf(1,"\"%s\" %s with You\n",{s,iff(length(regex(`^You`,s))?"starts":"does not start")})
?gsub(`[A-Z]`,"abCDefG","*")
?gsub(`[A-Z]`,"abCDefGH","(&)")
?gsub(`[A-Z]+`,"abCDefGH","(&)")
?gsub(`string`,s,"replacement")
s = gsub(`\ba\b`,s,"another") ?s
?gsub(`string`,s,"replacement")
