REPLACEREGEX
The REPLACEREGEX function is used to replace one string with another using regular expressions.
It has two variations of the syntax. The first one takes three arguments: the original string to look in, the regular expression to use, and the new string to replace with. The second one has an additional argument, which is a boolean value indicating whether the case of the item should be ignored.
Syntax
string REPLACEREGEX(string value, string expression, string newValue)
string REPLACEREGEX(string value, string expression, string newValue, bool ignoreCase)
Input
Object | Data Type | Description |
---|---|---|
value | String | The original string to look in. |
expression | String | The regular expression to use. |
newValue | String | The new string to put in place. |
ignoreCase | Boolean | A boolean indicating that the case of the item should be ignored. |
Example
An example use case for this function is when you need to replace certain characters in a filename that are not valid for filenames in SharePoint.
These characters include ~ " # % & * : < > ? / \ { | }
.
You can use the REPLACEREGEX function to replace any of these characters with an underscore using the following expression:
REPLACEREGEX(FileName, "[~\"#%&*:<>?/\\{|}]", "_")
This would replace any of these characters in the filename with an underscore.