The options argument must include the RegexOptions.IGNORE_CASE flag; otherwise a ValueError is raised. If only the pattern argument is provided, IGNORE_CASE is applied automatically. Python’s re module flags are accepted and translated (e.g., re.IGNORECASE becomes RegexOptions.IGNORE_CASE).
defcreate_regex_query(cls,pattern,options):...
Parameter
Type
Description
pattern
str
The regular expression pattern to match.
options
System.Text.RegularExpressions.RegexOptions
A bitwise combination of RegexOptions values that modify the regular expression. Must contain RegexOptions.IGNORE_CASE.
Returns: SearchQuery: A regular expression query.
Raises
Description
ValueError
If options does not contain the IGNORE_CASE flag.
Example
fromgroupdocs.searchimportSearchQuery,RegexOptions# Create a regex query with custom optionsregex_options=RegexOptions.IGNORE_CASE|RegexOptions.CULTURE_INVARIANTquery=SearchQuery.create_regex_query(r"^(.)\\1{1,}",regex_options)# Simple query using the default IGNORE_CASE optionsimple_query=SearchQuery.create_regex_query(r"(.)\1")
Aliases
These names call create_regex_query too, limited to the overloads listed.