See Vale Studio for a live editor
that can help you write and test your rules, including generating the compiled
regular expression.
The most common entry point for this extension point is the tokens key, which
is a list of strings or regular expressions to be transformed into a
word-bounded, non-capturing group:
yaml
Copy
tokens: - appears to be - arguably
Which, after compilation, becomes:
regex
Copy
(?i)(?m)\b(?:appears to be|arguably)\b
This is a convenience feature to avoid having to write the same boilerplate
for every token in a rule.
When you want more control over the regular expression, you can use the raw key instead:
yaml
Copy
extends: existencemessage: "Incorrect use of symbols in '%s'."ignorecase: trueraw: - $[d]* ?(?:dollars|usd|us dollars)
This allows you to write more complex patterns without having to worry about
any post-processing. Each entry in raw is concatenated with the previous
entry, allowing for improve commenting and readability of complex patterns.
The message key is a string that will be used to generate the final message
when a match is found. The (optional) %s placeholder will be replaced with
the matched text.