@@ -153,33 +153,46 @@ public func / <P: Pattern>(lhs: OrPattern<P, OneOf>, rhs: OneOf) -> OrPattern<P,
153
153
154
154
// MARK: Common patterns.
155
155
156
- /// Succeeds anywhere except for the end of input, and consumes 1 element.
156
+ /// Succeeds anywhere except for at the end of input, and consumes 1 element.
157
157
public let any = OneOf ( description: " any " , regex: #"[.\p{Zl}]"# ,
158
158
contains: { _ in true } )
159
- public let alphanumeric = OneOf ( description: " alphanumeric " , regex: #"(?:\p{Alphabetic}|\p{Nd})"# ,
160
- contains: { $0. isWholeNumber || $0. isLetter } )
161
- public let digit = OneOf ( description: " digit " , regex: #"\p{Nd}"# ,
162
- contains: { $0. isWholeNumber } )
159
+ /// Matches one character representing a letter, i.e. where `Character.isLetter` is `true`.
163
160
public let letter = OneOf ( description: " letter " , regex: #"\p{Alphabetic}"# ,
164
161
contains: { $0. isLetter } )
162
+ /// Matches one character representing a lowercase character, i.e. where `Character.isLowercase` is `true`.
165
163
public let lowercase = OneOf ( description: " lowercase " , regex: #"\p{Ll}"# ,
166
164
contains: { $0. isLowercase } )
165
+ /// Matches one character representing an uppercase character, i.e. where `Character.isUppercase` is `true`.
166
+ public let uppercase = OneOf ( description: " uppercase " , regex: #"\p{Lu}"# ,
167
+ contains: { $0. isUppercase } )
168
+ /// Matches one character representing a whole number, i.e. where `Character.isWholeNumber` is `true`.
169
+ public let digit = OneOf ( description: " digit " , regex: #"\p{Nd}"# ,
170
+ contains: { $0. isWholeNumber } )
171
+ /// Matches one letter or one digit.
172
+ public let alphanumeric = OneOf ( description: " alphanumeric " , regex: #"(?:\p{Alphabetic}|\p{Nd})"# ,
173
+ contains: { $0. isWholeNumber || $0. isLetter } )
174
+ /// Matches one character representing a newline, i.e. where `Character.isNewline` is `true`.
167
175
public let newline = OneOf ( description: " newline " , regex: #"\p{Zl}"# ,
168
176
contains: { $0. isNewline } )
177
+ /// Matches one character representing whitespace (including newlines), i.e. where `Character.isWhitespace` is `true`.
178
+ public let whitespace = OneOf ( description: " whitespace " , regex: #"\p{White_Space}"# ,
179
+ contains: { $0. isWhitespace } )
180
+ /// Matches one character representing punctuation, i.e. where `Character.isPunctuation` is `true`.
169
181
public let punctuation = OneOf ( description: " punctuation " , regex: #"\p{P}"# ,
170
182
contains: { $0. isPunctuation } )
183
+ /// Matches one character representing a symbol, i.e. where `Character.isSymbol` is `true`.
171
184
public let symbol = OneOf ( description: " symbol " , regex: #"\p{S}"# ,
172
185
contains: { $0. isSymbol } )
173
- public let uppercase = OneOf ( description: " uppercase " , regex: #"\p{Lu}"# ,
174
- contains: { $0. isUppercase } )
175
- public let whitespace = OneOf ( description: " whitespace " , regex: #"\p{White_Space}"# ,
176
- contains: { $0. isWhitespace } )
186
+ /// Matches one character representing a hexadecimal digit, i.e. where `Character.isHexDigit` is `true`.
177
187
public let hexDigit = OneOf ( description: " hexDigit " , regex: #"\p{Hex_Digit}"# ,
178
188
contains: { $0. isHexDigit } )
189
+ /// Matches one ASCII character, i.e. where `Character.isASCII` is `true`.
179
190
public let ascii = OneOf ( description: " ascii " , regex: #"[[:ascii:]]"# ,
180
191
contains: { $0. isASCII } ) // regex might also be [ -~] or [\x00-\x7F]
192
+ /// Matches one character representing a mathematical symbol, i.e. where `Character.isMathSymbol` is `true`.
181
193
public let mathSymbol = OneOf ( description: " mathSymbol " , regex: #"\p{Sm}"# ,
182
194
contains: { $0. isMathSymbol } )
195
+ /// Matches one character representing a currency symbol, i.e. where `Character.isCurrencySymbol` is `true`.
183
196
public let currencySymbol = OneOf ( description: " currencySymbol " , regex: #"\p{Sc}"# ,
184
197
contains: { $0. isCurrencySymbol } )
185
198
0 commit comments