### Escape reserved Characters

To escape reserved characters use the \ (backshlash) character.
Reference: http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html
The special regular expression characters are: . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -
Example 1
' Split a string with a RegEx Special Character, e.g. ?. The char ? has to be escaped using \.
Dim TestStr As String = "=?iso-8859-1?Q?Test Message?="
Log($"Example RegEx Split: ${TestStr}"$)
Dim Result() As String = Regex.Split("\?", TestStr)
Log($"Entries ${Result.Length}"$)
For Each s As String In Result
Log(s)
Next
Output:
Example RegEx Split: =?iso-8859-1?Q?Test Message?=
Entries 5
=
iso-8859-1
Q
Test Message
=
Example 2
' Split a string with a RegEx Special Character, e.g. |. The char | has to be escaped using \.
Dim str As String ="A|B|C"
Log($"Example RegEx Split: ${str}"$)
Dim strarr() As String = Regex.Split("\|",str)
Dim sb As StringBuilder
sb.Initialize
For i = 0 To strarr.Length - 1
sb.Append(strarr(i)).append(CRLF)
Next
Log(sb.ToString)
Output:
Example RegEx Split: A|B|C
A
B
C

Changed: , Category: RegEx, File: T6C240M1754.htm, ID: 1754