This function replaces the first substring matching the given regular expression with the given replacement.


replaceFirst(text, regex, replacement) #Output : Text



Parser expressionDescription


replaceFirst("Hello World", "l", "_")


This example returns the following text : "He_lo World"



Parameters used in this function

ParameterInput (data type)Description
text

Any given text.
regex

A valid regular expression that grabs the substring to be replaced.
replacement

This text will replace the substring found by the regex.



This function returns a


If you want to replace all matching occurrences with the replacement, have a look at the replaceAll() function.

replaceFirst("Hello World", "l", "_")replaceAll("Hello World", "l", "_")
"He_lo World""He__o Wor_d"


If you don't want to use a regular expression, have a look at the findReplaceFirst() function.




Use cases and examples



Parser function cloudreplaceFirst()
Map(tick)
Notes






Status
Tech review

Style guide




Short description

Replaces the first substring matching a given regular expression with a given replacement.

Output

Available since

Label