Function replaceFirst( str, regex, replacement )
- Description:
-
Replaces the first occurrence of a regular expression in a string with
a different substring value.
- Parameters:
-
- str (String)
- string to manipulate
- regex (String)
- regular expression to match in
str
- replacement (String)
- replacement string
- Return Value (String):
- same as
str
, but with the first match (if any) of
regex
replaced by replacement
- Example:
replaceFirst("Messier 61", "Messier ", "M-") = "M-61"
- Signature:
- String replaceFirst(String, String, String)