How do I escape the dot character in [^ pat]?
mcandre opened this issue · 1 comments
mcandre commented
I want to conduct a (negated) match pattern that specifically excludes periods. But I do not see the syntax for how to accomplish this.
I tried [^ '.']
, but that appears to expand the period to mean any symbol. Instead of a literal dot.
I also tried !(".")
, but in my context, peg complains that this would result in an infinite loop.
What is the right syntax for escaping a dot character in peg patterns?
kevinmehall commented
[^ '.']
is correct. This is a Rust pattern as would go in a match
arm, not a regex.
!(".")
will accept the empty string whenever the next character is not a dot, so (!("."))*
would infinite-loop since the inside of the loop doesn't consume anything and matches in the same place repeatedly.