Functions and Operators
The primary definition for a character match comes from:
Plain
match, iePlain "A"
matches the "A" character,Plain "Hello"
matches the word "Hello"OneOf
match, ieOneOf "AC"
matches on "A" and "C"Between
match, ieBetween 'a' 'z'
matches all characters between 'a' and 'z'- Macro, the macro module provides various pre-defined character classes, including wildcard
Macro.any
The Plain
and OneOf
constructions do not require character escaping. So Plain "."
matches the dot character. Macro.any
is used as wildcard-character.
Character Classes
Both OneOf
and Between
define character classes. Of wich also exist an inversion NotOneOf
and NotBetween
.
Character classes can be subtracted.
For example: Between 'a' 'z' - OneOf "klm" // matches all lowercase leters except "klm"
Operators
All Regular Expression (sub-)patterns can be used for these operators:
+
- concatenation, iePlain "A" + Plain "B"
(which is the same as Plain "AB");|||
- or, either the left or right side must match, iePlain "AB" ||| OneOf "CD"
matches: "AB", "C", "D";
Repetitions
One can use one of these repetitions:
ZeroOrMore
- the input sub-pattern may repeat zero or more times;OnceOrMore
- the input sub-pattern may repeat once or more times;RepeatRange
- the input sub-pattern may repeat between a min and max times;RepeatExact
- the input sub-pattern must repeat exactly the indicated times;Optional
- Zero or one;
Grouping
These ways are supported for groups:
Group
- Anonymous groupsNamedGroup
- NamedGroup
Usually, anonymous groups are useful in lesser complex patterns. The named groups help in complex patterns. Naming groups make it a lot easier to extract sub-strings from a matching result.
Conversion
The conversion module is used to create the pattern-string:
ToStringStartPattern
- Creates the pattern from the input, the start of the input string must match the start of the pattern;ToFullstringPattern
- Creates the pattern from the input, the full string must match the full pattern;ToPattern
- Creates the pattern from the input, the pattern-matching can start in the middle of the input string, and may match a substring;
The conversion module glues it together:
1: 2: 3: 4: 5: 6: 7: 8: |
|
Macro
The Macro
module contains various frequently used character classes and definitions:
Macro.any
- wildcard character, matches anything except newlineMacro.whitespace
- matches any whitespace, including space, tab, and moreMacro.nonWhitespace
- matches any non whitespaceMacro.bell
- matches the bell characterMacro.backspace
- matches the bachspace characterMacro.tab
- matches the tab characterMacro.carriageReturn
- matches the carriageReturn characterMacro.verticalTab
- matches the verticalTab characterMacro.formFeed
- matches the formFeed characterMacro.newLine
- matches the newLine characterMacro.escape
- matches the escape characterMacro.ascii
- matches the specified 8-bit hex characterMacro.utf16
- matches the specified 16-bit hex characterMacro.wordCharacter
- matches a word character, letters, digitsMacro.nonWordCharacter
- matches a non-word characterMacro.decimalDigit
- matches a decimal digit character 0..9Macro.nonDecimalDigit
- matches a non-decimal digit character 0..9Macro.namedBlock
- matches a character from the specified named block
from ReggerIt
type Regex =
new : pattern:string -> Regex + 2 overloads
member GetGroupNames : unit -> string[]
member GetGroupNumbers : unit -> int[]
member GroupNameFromNumber : i:int -> string
member GroupNumberFromName : name:string -> int
member IsMatch : input:string -> bool + 1 overload
member Match : input:string -> Match + 2 overloads
member MatchTimeout : TimeSpan
member Matches : input:string -> MatchCollection + 1 overload
member Options : RegexOptions
...
--------------------
Regex(pattern: string) : Regex
Regex(pattern: string, options: RegexOptions) : Regex
Regex(pattern: string, options: RegexOptions, matchTimeout: System.TimeSpan) : Regex
Regex.Match(input: string, pattern: string, options: RegexOptions) : Match
Regex.Match(input: string, pattern: string, options: RegexOptions, matchTimeout: System.TimeSpan) : Match