Optional
assertions"parse"
Optional
backreferencesHow to the parser will handle unresolved backreferences.
"disable"
The parser will replace all backreferences with an empty character class. This will cause all paths containing a backreference to be (effectively) removed.
E.g. (a*)(\1|b)
will be parsed as (a*)(([])|b)
which is equivalent to a*b
.
"throw"
The parser will throw an error when encountering a backreference that cannot be removed.
E.g. (a*)b\1
will throw but (a*)[^\s\S]\1
will not because the backreference will be removed anyway because
of the empty character class.
"unknown"
The parser will create a Unknown
node for each backreference that cannot be removed. The id of the node will
be raw string of the backreference.
Backreferences that have been resolved are not affected by this option.
"throw"
Optional
getUnknown
nodes have an id
property that can be used to identify the element that created the unknown. This
function can be used to control the id
value.
By default, the raw of the element will be used as its id.
Optional
maxThe maximum number of words a backreference can be replaced by.
Set this to 0 to disable resolving backreferences.
100
Optional
maxThe maximum number of nodes the parser is allowed to create.
If the regexes requires more nodes, a TooManyNodesError will be thrown.
10000
Optional
simplifyBy default, the parser will try to simplify the generated RE as much as possible.
If set to false
, all trivial simplifications will be disabled. This includes:
These simplifications might prevent certain backreferences or assertions from throwing an error. It's usually good to have them enabled since parsing is usually faster and the produced RE AST is smaller.
If the produced RE AST is supposed to be a literal translation, then simplifications have to be disabled.
true
How the parser will handle assertions.
"parse"
The parser will translate every assertion literally to an equivalent RE AST representation. Builtin assertions (e.g.
\b
,$
) will be transformed into equivalent assertions."disable"
The parser will disable all assertion by replacing them with an empty character class. This will cause all paths containing an assertion to be (effectively) removed.
"ignore"
The parser will ignore all assertion by replacing them with an empty group.
"throw"
The parser will throw an error when encountering a assertion that cannot be removed.
E.g.
a\B
will throw buta([]\b)(\b){0}
will not because none of the\b
s can be reached."unknown"
The parser will create a
Unknown
node for each assertion. The id of the node will be raw string of the assertion.