# $EPIC: sar.txt,v 1.2 2006/08/19 09:25:52 sthalik Exp $
$sar([c][i][g][r]/<search>/<replace>/<text>)
The arguments are composed of:
c
, i
, g
, and r
,c
, i
, g
, or r
, and is customarily a forward-slash,<search>
) that may not contain the delimiter to be removed,<replace>
) that may not contain the delimiter to be inserted in place of #3,<text>
) that MAY contain the delimiter to be transformed.
In its simple form, the string <text>
is returned with the first instance
of the string <search>
replaced with the string <replace>
. The search of
<search>
is case insensitive.
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. |
This is the general purpose search-and-replace function. It allows you to look for any arbitrary text substring in any text string, and replace it with another arbitrary substring. Any of the strings may consist of variables to expand at runtime.
resultant string
@ foo = [foobarblah] $sar(/oo/ee/booyamon) returns "beeyamon" $sar(/oo/ee/foofoo) returns "feefoo" $sar(g/oo/ee/foofoo) returns "feefee" $sar(r/oo/ee/foo) returns and sets $foo to "feebarblah"