Eliminating spaces and ALL special characters in a field by using replacex; What about applying several replacex in a formula?
In some cases, for whatever reason, you might want to eliminate any special character that appears in a field (special characters meaning anything that is not a number or an American letter) .
For instance, you might want to rename the content inside a field named Invoice ID so that its original value IN/2024-05-30: 143 gets converted to N20240530143 .
In order to do so, you just have to create a formula field and apply the following regular expression (RegEx):
replacex('Invoice ID', "\W", "")
"\W" is a Regular Expression which means "Matches any non-word character".
replacex('Invoice ID', "\W", "") stands for:
replace the matches of a given regular expression with a given string in a given text( 'The field where the data in form of text is' , any character that Matches any non-word character should be replaced by nothing.
NOW... MY QUESTION IS:
What if I want to apply several conditions? For instance, I want to eliminate the signs \, /, - by replacing them by "", that is , by nothing. (Replacing a string by nothing is equivalent to erase it).
I have tried the following syntax but Ninox will only eliminate whatever is indicated in the last line that is, in this example, replacex('Invoice ID', "\-", "") .
replacex('Invoice ID', "\\", "");
replacex('Invoice ID', "\/", "");
replacex('Invoice ID', "\-", "")
What is the proper syntax to use several replacex in one only formula?
2 Antworten
-
Put all characters in square brackets. Every character that has a meaning in regex must be preceded by a backslash in order to convert it to a literal, the other don't. The plus says: take one or many. \s are all spaces. Backslash convert "s" to regexfunction. Mirko
replacex('Invoice ID', "[\\/:-\s]+", "")
-
said:
What is the proper syntax to use several replacex in one only formula?Just to answer this in general: You can always use nested script for that purpose
replace(replace(replace(STRING,"OLD","NEW"),"OLD","NEW"),"OLD","NEW")
You´ll start in the inside, the outcome will then be replaced ... and so on ....
Content aside
- vor 5 MonatenZuletzt aktiv
- 2Antworten
- 19Ansichten
-
3
Folge bereits