STR strsed(STR rx, STR str, STR replace[, STR flags[, INT count]])
This functions similar sed in many unix systems. It searches for any occurrences of regexp in string and replaces them with replace, returning the result. The optional fourth argument is used to specify flags for sed. Flags are specified as a string containing any of the following alphabetic characters:
g Match the regular expression globally throughout the string s* Single match--Match the first occurrence only (default) c Case matters when matching i* Case doesn't matter when matching (default)
Flags followed by an asterisk (*) represent default behaviour if no flags are specified. For more information, see the section on Regular Expressions.
Examples:
strsed("foObar", "o+", "X")
=> "fXbar"strsed("foObar", "o+", "X", "c")
=> "fXObar"
The string ranges matched by the regular expression n the first string may be re-inserted into the resulting string by using '%n' tokens, where n represents the branch, from one to nine. This currently only works with branched regular expressions. Future revisions will expand upon this functionality.
Example:
strsed("foObar", "(o+)", "<%1>")
=> "fXbar"strsed("foObar", "(o+)", "<%1>", "c")
=> "fXObar"
The fifth argument count is intended to optimize the use of this function, and is generally not used. It is simply an optimizing guideline which specifies how many expected occurrences of the regular expression are expected in the string. This value is used when computing the initial size of the resulting string, to lower the amount of memory allocations which may have to be performed.
crypt() | explode() | lowercase() | match_begin() | match_pattern() | match_regexp() | match_template() | pad() | regexp() | strcmp() | strfmt() | strgraft() | strlen() | strsed() | strsub() | substr() | uppercase() | match_crypted() | split() | stridx()