String Functions

absstrlen after afterw ascii before beforew center chngw chr common copattern count decode diff encode filter findw fromw getmatches getrmatches index insertw isalpha isdigit isnum isnumber left leftpc leftw match mid midw msar notw numsort numwords pad pass pattern pop push regcomp regerror regexec regfree remw remws repeat rest restw reverse revw rfilter right rightw rindex rmatch rot13 rpattern rstrstr rword [sar] shift sort splice split strip strlen strstr tolower toupper tow tr translate uniq unshift word

Liam's BitchX Command Reference

BitchX scripting function $sar()

sar
Technical
This function searches for the given search string in the given text, and replaces if with the replacement text, if a match is found. The field delimiter may be any character; the first character found that is not a 'g' or 'r' is used.
Function
$sar()
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.
Usage
$sar([g][r]/<search>/<replace>/<text>)
Options
g replace all matches, not just the first r assume text is a variable name; assign return value to variable
Examples
@ 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"
See also $regexec() and $msar().


previous: rword next: sar