-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRange.cs
More file actions
65 lines (62 loc) · 2.26 KB
/
Range.cs
File metadata and controls
65 lines (62 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
namespace ReadableRex.Patterns
{
/// <summary>
/// Provides methods to create patterns representing ranges of characters or integers.
/// </summary>
/// <remarks>The <see cref="Range"/> class offers static methods to generate patterns for specific ranges
/// of characters or integers, as well as predefined patterns for common character ranges such as lowercase and
/// uppercase letters.</remarks>
public class Range
{
/// <summary>
/// Creates a new <see cref="Pattern"/> that represents a range of characters.
/// </summary>
/// <param name="from">The starting character of the range.</param>
/// <param name="to">The ending character of the range.</param>
/// <returns>A <see cref="Pattern"/> representing the range from <paramref name="from"/> to <paramref name="to"/>.</returns>
public static Pattern Of(char from, char to)
{
return new Pattern(from + "-" + to);
}
/// <summary>
/// Creates a new <see cref="Pattern"/> instance representing a range.
/// </summary>
/// <param name="from">The starting value of the range.</param>
/// <param name="to">The ending value of the range.</param>
/// <returns>A <see cref="Pattern"/> object that represents the specified range.</returns>
public static Pattern Of(int from, int to)
{
return new Pattern(from + "-" + to);
}
/// <summary>
/// Gets a pattern that matches any uppercase or lowercase letter.
/// </summary>
public static Pattern AnyLetter
{
get
{
return new Pattern("a-zA-Z");
}
}
/// <summary>
/// Gets a pattern that matches any lowercase letter from 'a' to 'z'.
/// </summary>
public static Pattern AnyLowercaseLetter
{
get
{
return new Pattern("a-z");
}
}
/// <summary>
/// Gets a pattern that matches any uppercase letter from A to Z.
/// </summary>
public static Pattern AnyUppercaseLetter
{
get
{
return new Pattern("A-Z");
}
}
}
}