Site Tools



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

Link to this comparison view

sar [2014/10/27 09:40] (current)
Line 1: Line 1:
 +# $EPIC: sar.txt,v 1.2 2006/08/19 09:25:52 sthalik Exp $
 +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. |
 +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"​
sar.txt ยท Last modified: 2014/10/27 09:40 (external edit)