Products | Versions |
---|---|
Spotfire Analyst | All Versions |
When using regular expressions and the RXReplace() function, you will often need to use escape characters that have special meaning in the regular expression language. Escape characters are needed on both the regular expression level and on the Spotfire expression level. This can be difficult to manage since multiple escape characters may be required. The usual metacharacters that need to be escaped are {}[]()^$.|*+? and \
String1.String2You would need to escape "." in the regular expression with a \ character. The regular expression to match the literal period would be:
\.
RXReplace([Column 1],"\\.","myReplacementText","g")
Since \ is a special character in regular expressions and in the RXReplace() function, this requires multiple levels of escape characters to match a literal \ character. If you want to match the literal \ in this string:
SomeText\What I want to capture\SomeOtherText
You would need to escape \ in the regular expression with a \ character. In regular expressions, you can match the \ character with:
\\In the Spotfire expression language, you would need to escape both of the \ characters that are required in the basic regular expression. The Spotfire expression with the RXReplace() function would be:
RXReplace([Column 1],"\\\\","myReplacementText","g")This would match all \ characters and replace it with 'myReplacementText'. \\\\ in the RXReplace() function matches a single literal \ character.
RXReplace([Column 1],"^.*\\\\(.*)\\\\.*$","$1","")