Union of types which can be converted to a RegexBuilder instance.
Native JavaScript RegExp are interpreted as is. Note, if start/end
markers are missing (i.e. ^/$) then there is an implicit .* at
the start and end:
RB(/^abc$/) // is like /^abc$/ RB(/abc/) // is like /^.*abc.*$/
Strings are interpreted as literal characters. For example, . is
interpreted as the literal dot character and not any character as in
regular expression:
RB('abc') // is like /^abc$/ RB('.') // is like /^\.$/
If no arguments (or undefined) is passed to RB, then it returns an
that matches no strings at all. This can be useful when constructing RB
instances programmatically.
['a', 'b', 'c'].reduce((acc, char) =>acc.or(RB(char)), RB()) // like /^(a|b|c)$/
This is also an example why RegexBuilder itself is accepted as input.
The final type ExtRegex is an internal representation that's likely not
interesting.
Union of types which can be converted to a
RegexBuilder
instance.Native JavaScript
RegExp
are interpreted as is. Note, if start/end markers are missing (i.e.^
/$
) then there is an implicit.*
at the start and end:Strings are interpreted as literal characters. For example,
.
is interpreted as the literal dot character and not any character as in regular expression:If no arguments (or
undefined
) is passed toRB
, then it returns an that matches no strings at all. This can be useful when constructingRB
instances programmatically.This is also an example why
RegexBuilder
itself is accepted as input.The final type
ExtRegex
is an internal representation that's likely not interesting.