Liking cljdoc? Tell your friends :D

lambdaisland.regal

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" 
raw docstring

*character-class*clj/s

source

*flavor*clj/s

source

-regal->irclj/smultimethod

source

assert-line-break-not-in-classclj/s

(assert-line-break-not-in-class)
source

char-class-escapeclj/s

(char-class-escape ch)
source

compileclj/s

(compile s)

Compile a regex pattern (string) to a regex.

Compile a regex pattern (string) to a regex.
sourceraw docstring

current-flavor?clj/s

(current-flavor? f)
source

escapeclj/s

(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.
sourceraw docstring

flavor-hierarchyclj/s

source

groupedclj/s

(grouped r)
source

left-padclj/s

(left-pad s len pad)
source

left-pad-strclj/s

(left-pad-str s len pad)
source

non-whitespace-ranges-codesclj/s

Character ranges that are not whitespace (the opposite of the above)

Character ranges that are not whitespace (the opposite of the above)
sourceraw docstring

non-whitespace-ranges-commonclj/s

Character ranges that are not whitespace (the opposite of the above)

Character ranges that are not whitespace (the opposite of the above)
sourceraw docstring

non-whitespace-ranges-re2clj/s

Character ranges that are not whitespace (the opposite of the above)

Character ranges that are not whitespace (the opposite of the above)
sourceraw docstring

normalizeclj/s

(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.

  • 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
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`
sourceraw docstring

patternclj/s

(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.
sourceraw docstring

quantifier->irclj/s

(quantifier->ir q rs opts)
source

quote-charclj/smultimethod

source

regexclj/s

(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.
sourceraw docstring

regex-patternclj/s

(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.
sourceraw docstring

runtime-flavorclj/s

(runtime-flavor)

The regex flavor that the current runtime understands.

The regex flavor that the current runtime understands.
sourceraw docstring

single-character?clj/s

(single-character? s)
source

tagged-form?clj/s

(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?
sourceraw docstring

token->irclj/smultimethod

source

unsupported-operationclj/s

(unsupported-operation op)
source

unsupported-operation-exceptionclj/s

(unsupported-operation-exception msg)
source

whitespace-char-codesclj/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.

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.
sourceraw docstring

whitespace-chars-commonclj/s

source

whitespace-chars-re2clj/s

source

with-flavorclj/smacro

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close