REGEXMASK
Calculates a System.Text.RegularExpressions.RegexOptions for use by other Regex functions. The returned value is an integer.
Syntax
RegexMask ( cultureInvariant, explicitCapture, ignoreCase, ignorePatternWhitespace, multiline, rightToLeft, singleLine )
Arguments
cultureInvariant
Type: int (0 or 1)
Specifies that cultural differences in language is ignored. See Performing Culture-Insensitive Operations in the RegularExpressions Namespace for more information.
explicitCapture
Type: int (0 or 1)
Specifies that the only valid captures are explicitly named or numbered groups of the form (?<name>…). This allows unnamed parentheses to act as noncapturing groups without the syntactic clumsiness of the expression (?:…).
ignoreCase
Type: int (0 or 1)
Specifies case-insensitive matching.
ignorePatternWhitespace
Type: int (0 or 1)
Eliminates unescaped white space from the pattern and enables comments marked with #. However, the IgnorePatternWhitespace value does not affect or eliminate white space in character classes.
multiline
Type: int (0 or 1)
Multiline mode. Changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.
rightToLeft
Type: int (0 or 1)
Specifies that the search will be from right to left instead of from left to right.
singleline
Type: int (0 or 1)
Specifies single-line mode. Changes the meaning of the dot (.) so it matches every character (instead of every character except \n).
Return Value
Type: int
SELECT RegexMask(0, 0, 0, 1, 0, 0, 1)
REGEXISMATCH
Indicates whether the specified regular expression finds a match in the specified input string, using the specified matching options (see System.Text.RegularExpressions.IsMatch)
Syntax
RegexIsMatch ( input, pattern, options )
Arguments
input
Type: string
The string to search for a match.
pattern
Type: string
The regular expression pattern to match.
options
Type: int
A bitwise combination of the enumeration values that provide options for matching. Use RegexMask to calculate the options.
Return Value
Type: int
1 if the regular expression finds a match; 0 otherwise.
SELECT RegexIsMatch("Type", "^T", 0)
REGEXREPLACE
In a specified input string, replaces all strings that match a specified regular expression with a specified replacement string. Specified options modify the matching operation (see System.Text.RegularExpressions.Replace)
Syntax
RegexReplace ( input, pattern, replacement, options )
Arguments
input
Type: string
The string to search for a match.
pattern
Type: string
The regular expression pattern to match.
replacement
Type: string
The replacement string.
options
Type: int
A bitwise combination of the enumeration values that provide options for matching. Use RegexMask to calculate the options.
Return Value
Type: string
A new string that is identical to the input string, except that the replacement string takes the place of each matched string.
SELECT RegexReplace("Type", "^T", "t", 0)
REGEXSPLITSPELLCHECKVALID
Splits the specified input string into words, and spell checks the words that do not match the ignore pattern.
Syntax
RegexSplitSpellChekValid ( input, splitPattern, ignorePattern, options, spellCheckerKey )
Arguments
input
Type: string
The string to split and spell check.
splitPattern
Type: string
The pattern to use to split the input string.
ignorePattern
Type: string
The pattern to use to match the parts that are to be skipped spell checking.
options
Type: int
A bitwise combination of the enumeration values that provide options for matching. Use RegexMask to calculate the options.
spellCheckerKey
Type: int
An internally managed value of the dictionary to use for spell checking. Use SpellCheckAddDictionary to configure dictionaries.
Return Value
Type: string
A multiline string; each line contains the mispelled words, with suggestions.
DECLARE @dictkey NVARCHAR
SET @dictkey = SpellCheckAddDictionary(NULL, NULL, NULL, NULL, 'en-CA', 0)
SELECT RegexSplitSpellCheckValid("The foxs jumpz over da fence.", " ", null, 0, @dictkey)
Returns
foxs - fox foxes fox's fobs foes
jumpz - jump jumps jumpy jump z
da - DA ad a d Ada
REGEXSPLITGETMATCH
Splits the specified input string into words, and returns the word at the specified index (one based, i.e. the first is 1, the last is -1). Positive index means word from the left, negative index means from word the right.
Syntax
RegexSplitGetMatch ( input, splitPattern, validPattern, options, index )
Arguments
input
Type: string
The string to split and spell check.
splitPattern
Type: string
The pattern to use to split the input string.
validPattern
Type: string
The pattern used to validate the word. Reserved, pass null.
options
Type: int
A bitwise combination of the enumeration values that provide options for matching. Use RegexMask to calculate the options.
index
Type: int
The position of the word in the list. Positive index means word from the left, negative index means from word the right.
Return Value
Type: string
The word that was matched, null if not found.
SELECT RegexSplitGetMatch("The foxs jumpz over da fence.", " ", null, 0, -1)
Returns
fence
REGEXSPLIT
Splits an input string into an array of substrings at the positions defined by a specified regular expression pattern. Specified options modify the matching operation.
Syntax
RegexSplit ( input, splitPattern, validatePattern, options )
Arguments
input
Type: string
The string to split and spell check.
splitPattern
Type: string
The pattern to use to split the input string.
validatePattern
Type: string
The pattern used to validate the word.
options
Type: int
A bitwise combination of the enumeration values that provide options for matching. Use RegexMask to calculate the options.
Return Value
Type: Table
The table is made up of the following columns:
Index |
int |
not null |
Value |
string |
null |
Valid |
int |
null, 0 or 1 |
SELECT * FROM RegexSplit("The fox jumps over the fence.", "\.| ", null, 0)
Returns
Index |
Value |
Valid |
0 |
The |
|
1 |
fox |
|
2 |
jumps |
|
3 |
over |
|
4 |
the |
|
5 |
fence |
|
6 |
|
|