These functions are a version of edit() that uses regular expressions.
The part of <string> that matches the <regexp> is replaced by the
evaluated <replacement>, with $<number> in <replacement> expanded to the
corresponding matching sub-expression of <regexp>, with $0 the entire
matched section. If you use named sub-expressions (?P<foo>subexpr), they
are
referred with with $<foo> (Note that the <>'s are literal).
regedit() only replaces the first match. regeditall() replaces all
matches.
The versions ending in i are case insensitive. The <replacement>
argument is evaluated once for each match, allowing for more complex
transformations than is possible with straight replacement.
Examples:
> say regedit(this test is the best string, (?P<char>.)est, $<char>rash)
You say "this trash is the best string"
> say regeditall(this test is the best string, (.)est, [capstr($1)]rash)
You say "this Trash is the Brash string"
Original issue 344 created by brazilofmux on 2007-06-27T18:31:47.000Z:
TinyMUX currently does not have the regedit() family of functions; some would suggest it should.
From Penn's help regedit():
help regedit REGEDIT() regedit(<string>, <regexp>, <replacement>[, ... , <regexpN>, <replaceN>]) regediti(<string>, <regexp>, <replacement>[, ... , <regexpN>, <replaceN>]) regeditall(<string>, <regexp>, <replacement>[, ... , <regexpN>, <replaceN>]) regeditalli(<string>, <regexp>, <replacement>[, ... , <regexpN>, <replaceN>])
These functions are a version of edit() that uses regular expressions. The part of <string> that matches the <regexp> is replaced by the evaluated <replacement>, with $<number> in <replacement> expanded to the corresponding matching sub-expression of <regexp>, with $0 the entire matched section. If you use named sub-expressions (?P<foo>subexpr), they are referred with with $<foo> (Note that the <>'s are literal).
regedit() only replaces the first match. regeditall() replaces all matches. The versions ending in i are case insensitive. The <replacement> argument is evaluated once for each match, allowing for more complex transformations than is possible with straight replacement.
Examples: > say regedit(this test is the best string, (?P<char>.)est, $<char>rash) You say "this trash is the best string" > say regeditall(this test is the best string, (.)est, [capstr($1)]rash) You say "this Trash is the Brash string"
See also: edit(), regmatch()