Site Tools


sar
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


sar [2014/10/27 09:40] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +# $EPIC: sar.txt,v 1.2 2006/08/19 09:25:52 sthalik Exp $
 +======Synopsis:======
 +$__sar__([c][i][g][r]/<search>/<replace>/<text>)
 +
 +======Technical:======
 +The arguments are composed of:
 +   - zero or more of the options ''c'', ''i'', ''g'', and ''r'',
 +   - a delimiter which can be any character other than ''c'', ''i'', ''g'', or ''r'', and is customarily a forward-slash,
 +   - 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 #3,
 +   - a delimiter; the same as (2), and
 +   - a string of text (''<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. |
 +
 +======Practical:======
 +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.
 +
 +======Returns:======
 +resultant string
 +
 +======Examples:======
 +<file>
 +@ 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"
 +</file>
  
sar.txt · Last modified: 2014/10/27 09:40 by 127.0.0.1