Expand description
Pattern
s are one of the more powerful ways to query text inside Harper, especially for beginners.
Through the PatternLinter
trait, they make it much easier to
build Harper rules.
See the page about SequencePattern
for a concrete example of their use.
Structs§
- All
- A
Pattern
that consumes a list of other patterns and only matches if all the child patterns do. - AnyCapitalization
- A
Pattern
that matches any capitalization of a provided word. - AnyPattern
- A
Pattern
that will match any single token. - Consumes
Remaining Pattern - A pattern that wraps another pattern. If the wrapped pattern matches the remainder of the input, it returns the input’s length. Otherwise, it matches nothing.
- Either
Pattern - A pattern that returns the value of the longest match in a list.
- Exact
Phrase - Implies
Quantity - This struct does two things.
- Indefinite
Article - Invert
- A struct that matches any pattern except the one provided.
- IsNot
Title Case - Will match full length of wrapped pattern only if the matched text is not already title case.
- Naive
Pattern Group - A naive pattern collection that naively iterates through a list of patterns, returning the first one that matches.
- Noun
Phrase - Repeating
Pattern - A pattern that will match one or more repetitions of the same pattern.
- Sequence
Pattern - A pattern that checks that a sequence of other patterns match.
There are specific extension methods available, but you can also use
Self::then
to add arbitrary patterns. - Similar
ToPhrase - Singular
Subject - Split
Compound Word - A
Pattern
that looks for valid words accidentally split by whitespace. - Token
Kind Pattern Group - Whitespace
Pattern - Word
Pattern Group - A pattern collection to look for patterns that start with a specific word.
- WordSet