The public API of wreck
.
Notes:
nil
, this library does minimal argument
checking, since the rules for regular expressions vary from platform to
platform, and it is a first class requirement that callers be allowed to
construct platform specific regular expressions if they wish.java.util.regex.PatternSyntaxException
class.SyntaxError
s.#"{}"
(error on JVM, fine but nonsencial on
JS) and #"{1}"
(fine but nonsensical on JVM, but error on JS).The public API of `wreck`. Notes: * Apart from passing through `nil`, this library does minimal argument checking, since the rules for regular expressions vary from platform to platform, and it is a first class requirement that callers be allowed to construct platform specific regular expressions if they wish. * As a result, all functions have the potential to throw platform-specific exceptions if the resulting regular expression is syntactically invalid. * On the JVM, these will typically be instances of the `java.util.regex.PatternSyntaxException` class. * On JavaScript, these will typically be a `SyntaxError`s. * Platform specific behaviour is particularly notable for short / empty regular expressions, such as `#"{}"` (error on JVM, fine but nonsencial on JS) and `#"{1}"` (fine but nonsensical on JVM, but error on JS).
(=' _)
(=' re1 re2)
(=' re1 re2 & more)
Equality for regexes, defined by having equal String
representations. This
means that equivalent regexes (e.g. #"..."
and #".{3}"
will not be
considered equal.
Notes: this is only needed in ClojureJVM (ClojureScript correctly implements equality for regexes).
Equality for regexes, defined by having equal `String` representations. This means that _equivalent_ regexes (e.g. `#"..."` and `#".{3}"` will _not_ be considered equal. Notes: this is only needed in ClojureJVM (ClojureScript correctly implements equality for regexes).
(alt & res)
Returns a regex that will match any one of res
, via alternation.
Notes:
res
will only appear once in the result.Returns a regex that will match any one of `res`, via alternation. Notes: * Duplicate elements in `res` will only appear once in the result.
(alt-grp & res)
[grp] on each element in res
, then [alt].
[grp] on each element in `res`, then [alt].
(and' a b)
(and' a b s)
Returns an 'and' regex that will match a
and b
in any order, and with the
s
eparator regex (if provided) between them. This is implemented as
ASB|BSA
, which means that A and B must be distinct (must not match the same
text).
Notes:
Returns an 'and' regex that will match `a` and `b` in any order, and with the `s`eparator regex (if provided) between them. This is implemented as `ASB|BSA`, which means that A and B must be distinct (must not match the same text). Notes: * May optimise the expression (via de-duplication in [alt]).
(and-grp a b)
(and-grp a b s)
As for [and'], but each element in the alternation is grouped with [grp].
Notes:
-grp
fns, this one does not accept any number of res.As for [and'], but each element in the alternation is grouped with [grp]. Notes: * Unlike most other `-grp` fns, this one does _not_ accept any number of res. * May optimise the expression (via de-duplication in [alt]).
(cg & res)
As for [grp], but uses a capturing group.
As for [grp], but uses a capturing group.
(esc s)
Escapes s
(a String
) for use in a regex, returning a String
. Note that
unlike most other fns in this namespace, this one does not support a regex
as an input, nor return a regex as an output.
Escapes `s` (a `String`) for use in a regex, returning a `String`. Note that unlike most other fns in this namespace, this one does _not_ support a regex as an input, nor return a regex as an output.
(exn n re)
Returns a regex where re
will match exactly n
times.
Returns a regex where `re` will match exactly `n` times.
(grp & res)
As for [join], but encloses the joined res
into a single non-capturing
group.
As for [join], but encloses the joined `res` into a single non-capturing group.
(join & res)
Returns a regex that is all of the res
joined together. Each element in
res
can be a regex, a String
or something that can be turned into a
String
(including numbers, etc.). Returns nil
when no res
are provided,
or they're all nil
.
Returns a regex that is all of the ` res` joined together. Each element in `res` can be a regex, a `String` or something that can be turned into a `String` (including numbers, etc.). Returns `nil` when no `res` are provided, or they're all `nil`.
(n2m n m re)
Returns a regex where re
will match from n
to m
times.
Returns a regex where `re` will match from `n` to `m` times.
(ncg nm & res)
As for [grp], but uses a named capturing group named nm
. Returns nil
if
nm
is nil
or blank. Throws if nm
is an invalid name for a named capturing
group (alphanumeric only, must start with an alphabetical character, must be
unique within the regex).
As for [grp], but uses a named capturing group named `nm`. Returns `nil` if `nm` is `nil` or blank. Throws if `nm` is an invalid name for a named capturing group (alphanumeric only, must start with an alphabetical character, must be unique within the regex).
(nom n re)
Returns a regex where re
will match n
or more times.
Returns a regex where `re` will match `n` or more times.
(oom re)
Returns a regex where re
will match one or more times.
Returns a regex where `re` will match one or more times.
(opt re)
Returns a regex where re
is optional.
Returns a regex where `re` is optional.
(or' a b)
(or' a b s)
Returns an 'inclusive or' regex that will match a
or b
, or both, in any
order, and with the s
eparator regex (if provided) between them. This is
implemented as ASB|BSA|A|B
, which means that A and B must be distinct (must
not match the same text).
Notes:
Returns an 'inclusive or' regex that will match `a` or `b`, or both, in any order, and with the `s`eparator regex (if provided) between them. This is implemented as `ASB|BSA|A|B`, which means that A and B must be distinct (must not match the same text). Notes: * May optimise the expression (via de-duplication in [alt]).
(or-grp a b)
(or-grp a b s)
As for [or'], but each element in the alternation is grouped with [grp].
Notes:
-grp
fns, this one does not accept any number of res.As for [or'], but each element in the alternation is grouped with [grp]. Notes: * Unlike most other `-grp` fns, this one does _not_ accept any number of res. * May optimise the expression (via de-duplication in [alt]).
(qot s)
Quotes s
(a String
) for use in a regex, returning a regex. Note that
unlike most other fns in this namespace, this one does not support a regex
as an input.
Quotes `s` (a `String`) for use in a regex, returning a regex. Note that unlike most other fns in this namespace, this one does _not_ support a regex as an input.
(xor' a b)
Returns an 'exclusive or' regex that will match a
or b
, but not both.
This is identical to [alt] called with 2 arguments, and is provided as a
convenience for those who might be building up large logic based regexes and
would prefer to use more easily understood logical operator names throughout.
Notes:
Returns an 'exclusive or' regex that will match `a` or `b`, but _not_ both. This is identical to [alt] called with 2 arguments, and is provided as a convenience for those who might be building up large logic based regexes and would prefer to use more easily understood logical operator names throughout. Notes: * May optimise the expression (via de-duplication in [alt]).
(xor-grp a b)
As for [xor'], but each element in the alternation is grouped with [grp].
Notes:
-grp
fns, this one does not accept any number of res.As for [xor'], but each element in the alternation is grouped with [grp]. Notes: * Unlike most other `-grp` fns, this one does _not_ accept any number of res. * May optimise the expression (via de-duplication in [alt]).
(zom re)
Returns a regex where re
will match zero or more times.
Returns a regex where `re` will match zero or more times.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close