Skip to content

Is there a parser that consumes a string that matches a regex? #173

Answered by renggli
leeflix asked this question in Q&A
Discussion options

You must be logged in to vote

Correct, have a look at the method documentation:

/// Returns a parser that accepts a single character of a given character set
/// provided as a string.
///
/// Characters match themselves. A dash `-` between two characters matches the
/// range of those characters. A caret `^` at the beginning negates the pattern.
///
/// For example, the parser `pattern('aou')` accepts the character 'a', 'o', or
/// 'u', and fails for any other input. The parser `pattern('1-3')` accepts
/// either '1', '2', or '3'; and fails for any other character. The parser
/// `pattern('^aou') accepts any character, but fails for the characters 'a',
/// 'o', or 'u'.
@useResult
Parser<String> pattern(String element, [

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by renggli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #172 on June 06, 2024 14:45.