Regex Replace only first

Regex Replace only first

The description of this function is:

Replaces all occurrences of a specified regular expression pattern with a replacement string.

I want to only replace the first occurence, how do I do that
Hi Kevin!

In your case I think you can just you 'find' and/or 'replace' functions provided by de platform.
replace also does everything afaik.

I think you have to fiddle with regex_search which will returns the pattern and the first index.

out of my head you prolly gonna do something like.

substr(searchString,0, indexFound) + substr(searchString, indexFound+ length(pattern), length(searchString) - indexFound - length(pattern))

Hi Kevin,

Although built-in find and replace works in a lot of cases; when replacing for instance only the first occurance in a line and having the need to go through a whole set of lines RegEx replacement will probable be the quickest option.

There is a very good online regex tester:

In general if you won't do a global replacement only the first occurrence will be replaced: