msar
Table of Contents
Synopsis:
$msar([c][i][g][r]/[<search>/<replace>/]*<text>)
Technical:
The arguments are composed of:
- zero or more of the options
c
,i
,g
, andr
, - a delimiter which can be any character other than
c
,i
,g
, orr
, and is customarily a forward-slash, - ZERO OR MORE SETS OF SUBSTITUTIONS:
- some text (
<search>
) that may not contain the delimiter to be removed, - a delimiter; the same as (2),
- some text (
<replace>
) that may not contain the delimiter to be inserted in place of (3a), - a delimiter; the same as (2),
- a string of text (
<text>
) that MAY NOT contain the delimiter to be transformed.
No matter what, <text>
is always the text that follows the final delimiter.
If properly formed, there should always be an odd number of delimiters in
the arguments. But if there is an even number of delimiters, this would
result in a substutition with a <search>
but no <replace>
. This <search>
would be ignored as a syntax error.
In its simple form, the string <text>
is returned with the first instance
of each of the <search>
strings replaced with each of the corresponding
<replace>
strings. The matching of <search>
is case-insensitive by default.
The options modify this behavior:
c | The search for <search> should be case-sensitive. |
i | The search for <search> should be case-insensitive (this is the default, and the option is only included for backwards-compatibility). |
g | All instances of <search> should be replaced with <replace> . You must be careful that the contents of <replace> do not match <search> because this would cause it to be infinitely replaced. |
r | The <text> argument is the name of a variable. The search and replace is performed on the value of this variable, and the result is assigned back to the variable. |
Returns:
the resultant string
Examples:
$msar(/as/xy/asdf) returns "xydf" $msar(/as/xy/yd/42/asdf) returns "x42f" $msar(/e/he/pi/ll/c/o/epic) returns "hello"
msar.txt · Last modified: 2014/10/27 09:40 by 127.0.0.1