ExpRegSub

From Odwiki

Jump to: navigation, search

This one of the odWiki CustomExpressions which uses PERL to return a substitution of a RegularExpression

string ExpRegSub(string source; string from; string to;)
{
  string perlstr = "";
  perlstr = "echo '" + source + "' | perl -pe 's/" + from + "/" + to + "/g'";
  return system(perlstr);
}

e.g.

hscript> echo `~ExpRegSub("hello","ll","foobar")`
hefoobaro

credit: AntioneDurr

© 2009 od[force].net | advertise