Replace
str_replace¶
Replace occurrences of a pattern in a string. Replaces all occurrences by default; pass a count to limit replacements. The '/' sed delimiter is automatically escaped in match and replacement, so literal '/' characters in either argument are handled correctly.
Arguments¶
- $1 (string): The input string
- $2 (string): The pattern to search for (sed-compatible regex)
- $3 (string): The replacement string
- $4 (int): Optional: maximum number of replacements (default: all)
Exit codes¶
- 0: Success
- 1: Count is not a positive integer
Output on stdout¶
- String with replacements applied