RangeExpression Class |
Namespace: Ookii.Jumbo.Topology
The RangeExpression type exposes the following members.
Name | Description | |
---|---|---|
RangeExpression |
Initializes a new instance of the RangeExpression class.
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Match(String) |
Matches the specified string against the pattern.
| |
Match(String, Boolean) |
Matches the specified string against the pattern.
| |
ToString |
Returns a String that represents this instance.
(Overrides ObjectToString.) |
The RangeExpression class allows you to match strings containing ranges of numbers.
String matching is done using a pattern. This pattern, in addition to regular text, can contain numeric ranges of the form "[n-m]" where n and m are both numbers, e.g. "[001-299]". The ranges are inclusive.
The number of characters in the lower bound of the range determines the minimum number of characters; e.g. the expression "foo[001-299]" will match "foo001" but not "foo1", whereas the expression "foo[1-299]" would match either.
The number of characters in the upper bound determines the maximum number of characters; e.g. the expression "foo[1-099] matches "foo050" and "foo50" but not "foo0050".
In addition to ranges, you can also use alternation with the | character. For example, "foo[00-50]|bar[51-99]" will match both e.g. "foo25" and "bar75".
You can also group subexpressions in parentheses for use with alternation. For example "(foo|bar)[00-50]" will match both e.g. "foo25" and "bar25".