Compile Regal syntax to regex patterns.
(regex [:cat :start [:class [\a \z] [\A \Z] [\0 \9] _ -] "@" [:repeat [:class [\0 \9]] 3 5] [:* [:not .]] [:alt "com" "org" "net"] :end]) #"\A[a-zA-Z0-9_-]\Q@\E[0-9]{3,5}[^.]*(?:\Qcom\E|\Qorg\E|\Qnet\E)\z"
Compile Regal syntax to regex patterns. >>> (regex [:cat :start [:class [\a \z] [\A \Z] [\0 \9] \_ \-] "@" [:repeat [:class [\0 \9]] 3 5] [:* [:not \.]] [:alt "com" "org" "net"] :end]) #"\A[a-zA-Z0-9_-]\Q@\E[0-9]{3,5}[^.]*(?:\Qcom\E|\Qorg\E|\Qnet\E)\z"
(compile s)
Compile a regex pattern (string) to a regex.
Compile a regex pattern (string) to a regex.
(escape s)
Escape a regex pattern, so that, when compiled to a regex object, it will match all characters literally.
Escape a regex pattern, so that, when compiled to a regex object, it will match all characters literally.
Character ranges that are not whitespace (the opposite of the above)
Character ranges that are not whitespace (the opposite of the above)
Character ranges that are not whitespace (the opposite of the above)
Character ranges that are not whitespace (the opposite of the above)
Character ranges that are not whitespace (the opposite of the above)
Character ranges that are not whitespace (the opposite of the above)
(normalize form)
Returns a canonical, normalized version of a Regal form. Normalization is idempotent. This function is mostly here to allow us to do property-based testing on Regal itself, in particular we guarantee that for normalized form compiling to regex, then parsing again returns the same form. Might be useful for some other cases, e.g. if you want to memoize compiled regexes.
Parsing generally returns canonical (normalized) forms, so there is no need to
normalize the result of lambdaisland.regal.parse/parse
.
[:cat ...]
groupings[:alt ...]
grouping[:class ...]
groups that only wrap a single character or token (keyword):null
with [:char 0]
[:not :whitespace]
with :non-whitespace
Returns a canonical, normalized version of a Regal form. Normalization is idempotent. This function is mostly here to allow us to do property-based testing on Regal itself, in particular we guarantee that for normalized form compiling to regex, then parsing again returns the same form. Might be useful for some other cases, e.g. if you want to memoize compiled regexes. Parsing generally returns canonical (normalized) forms, so there is no need to normalize the result of [[lambdaisland.regal.parse/parse]]. - Turns characters into strings (Java) - removes unnecessary `[:cat ...]` groupings - removes single element `[:alt ...]` grouping - join consecutive strings - remove `[:class ...]` groups that only wrap a single character or token (keyword) - replace `:null` with `[:char 0]` - replace `[:not :whitespace]` with `:non-whitespace`
(pattern form)
(pattern form opts)
Convert a Regal form to a regex pattern as a string.
Convert a Regal form to a regex pattern as a string.
(regex form)
(regex form {:keys [resolver] :as opts})
Convert a Regal form into a platform-specific regex pattern object.
Can take an options map:
:resolver
a function/map used to resolve namespaced keywords inside Regal
expressions.Convert a Regal form into a platform-specific regex pattern object. Can take an options map: - `:resolver` a function/map used to resolve namespaced keywords inside Regal expressions.
(regex-pattern r)
Regex to string, remove the slashes that JavaScript likes to add. This will drop any regex modifiers.
Regex to string, remove the slashes that JavaScript likes to add. This will drop any regex modifiers.
(runtime-flavor)
The regex flavor that the current runtime understands.
The regex flavor that the current runtime understands.
(tagged-form? tag form)
Is the given form
a vector with the given tag
as first element?
Is the given `form` a vector with the given `tag` as first element?
These are characters with the Unicode whitespace property. In JavaScript these are all matched by \s, except for NEXT LINE and MONGOLIAN VOWEL SEPARATOR. In Java \s only matches the ASCII one. In Regal :whitespace emulates the JavaScript semantics of \s.
These are characters with the Unicode whitespace property. In JavaScript these are all matched by \s, except for NEXT LINE and MONGOLIAN VOWEL SEPARATOR. In Java \s only matches the ASCII one. In Regal :whitespace emulates the JavaScript semantics of \s.
(with-flavor flavor & body)
Set the flavor of regex to use for generating and parsing regex patterns.
Defaults to the flavor understood by the runtime. flavor
can be :ecma
,
:java8
(Java 8) or :java9
(Java 9 or later). Earlier Java versions are not
officially supported, meaning some patterns will behave differently.
Set the flavor of regex to use for generating and parsing regex patterns. Defaults to the flavor understood by the runtime. `flavor` can be `:ecma`, `:java8` (Java 8) or `:java9` (Java 9 or later). Earlier Java versions are not officially supported, meaning some patterns will behave differently.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close