Hi we are trying to truncate the first 5 characters of a field and for some reason the Replace via Regular Expression processor doesn’t seem to ‘work”
We have tried:
^(.{1,5})(?:|$)
Regex101.com seems to match it correctly
and which replaces the first 5 characters with blank so then we tried this
^.{5}(.*)
which seems to replace all of it with a blank…
Help please.
If anyone can create a small library of useful regex strings for use that would be really appreciated!
Best answer by cyprien.oger
Hello Yvonne,
I believe there is a misunderstanding regarding what the Replace via Regular Expression Processor does. Its role is to remove or replace part of a text and therefore, the regular expression is used to match the part of the text that will be removed/replaced (and not the one that will be kept).
In your example, you may need instead to match all characters except the first 5 characters of the string, such as: (?<=^.{5}).*
Without the Replace via Regular Expression ProcessorWith the Replace via Regular Expression Processor
I believe there is a misunderstanding regarding what the Replace via Regular Expression Processor does. Its role is to remove or replace part of a text and therefore, the regular expression is used to match the part of the text that will be removed/replaced (and not the one that will be kept).
In your example, you may need instead to match all characters except the first 5 characters of the string, such as: (?<=^.{5}).*
Without the Replace via Regular Expression ProcessorWith the Replace via Regular Expression Processor