int s.findreplace(findwhat [replaceto] [flags] [delim] [from])
s - str variable.
findwhat - string to find.
replaceto - replacement string. Default: "".
flags - combination of values listed below. Default: 0.
| 1 | case insensitive. |
| 2 | whole word. |
| 4 | single replacement. |
| 8 | repeat replacement until s will not contain substrings that match findwhat. Without this flag, the result string can contain new such substrings. For example, if in string "abbcc" is replaced "bc" to "", the result is "abc". With this flag, the result is "a". |
| 16 | replace to [0] character. replaceto is not used and can be "". |
| 32 | replace [0] character (QM 2.2.0). findwhat is not used and can be "". |
| 256 | delim is table of delimiters. |
delim - delimiter characters. String. Default: "".
from - start from here. Zero-based character index in s. Default: 0.
Searches in s for findwhat, and replaces to replaceto. If flag 2 is set, searches for substrings delimited by characters in delim, else delim is ignored.
If flag 4 is not set, replaces all found findwhat and returns the number of replacements. If flag 4 is set, replaces only the first found findwhat, and returns zero-based character index of findwhat in s.
str s="one two one twoo one.two" s.findreplace("two" "THREE" 2 " .") now s is "one THREE one twoo one.THREE" s="one two one two one two" s.findreplace("two" "THREE" 4 "" 5) now s is "one two one THREE one two" remove empty lines: s="one[][][][][]two" s.findreplace("[][]" "[]" 8)