Liking cljdoc? Tell your friends :D

com.blockether.skjema.regex

ECMAScript regular expressions in the dialect java.util.regex speaks.

pattern and patternProperties hold ECMA-262 regular expressions, and Java's are ALMOST the same language. Every difference between the two is silent - the pattern compiles on both sides and matches different strings:

  • \s is six ASCII characters in Java; in ECMAScript it is every space separator, both line terminators and the byte-order mark,
  • \v is one vertical tab in ECMAScript and a whole class of vertical whitespace in Java,
  • \ca and \cA are the same control character in ECMAScript, which takes the letter modulo 32; Java exclusive-ors with 64 and answers !,
  • \b inside a character class is a backspace in ECMAScript,
  • \0 is NUL in ECMAScript and the start of an octal escape in Java,
  • \p{Letter} and \p{Script=Greek} are \p{L} and \p{IsGreek}.

One scan answers both questions this library asks of a pattern: how Java spells it, and whether it was ECMAScript in the first place - which is what format: regex asserts, and why (?P<name>...), (?#comment) and the inline flags (?i) are refused even though Java understands two of them.

ECMAScript regular expressions in the dialect java.util.regex speaks.

`pattern` and `patternProperties` hold ECMA-262 regular expressions, and
Java's are ALMOST the same language. Every difference between the two is
silent - the pattern compiles on both sides and matches different strings:

- `\s` is six ASCII characters in Java; in ECMAScript it is every space
  separator, both line terminators and the byte-order mark,
- `\v` is one vertical tab in ECMAScript and a whole class of vertical
  whitespace in Java,
- `\ca` and `\cA` are the same control character in ECMAScript, which
  takes the letter modulo 32; Java exclusive-ors with 64 and answers `!`,
- `\b` inside a character class is a backspace in ECMAScript,
- `\0` is NUL in ECMAScript and the start of an octal escape in Java,
- `\p{Letter}` and `\p{Script=Greek}` are `\p{L}` and `\p{IsGreek}`.

One scan answers both questions this library asks of a pattern: how Java
spells it, and whether it was ECMAScript in the first place - which is what
`format: regex` asserts, and why `(?P<name>...)`, `(?#comment)` and the
inline flags `(?i)` are refused even though Java understands two of them.
raw docstring

ecma?clj

(ecma? p)

Whether p is an ECMAScript regular expression, which is what format: regex asserts. Compiling under Java is not enough on its own: Java accepts (?i), \a and refuses (?#comment) for reasons of its own.

Whether `p` is an ECMAScript regular expression, which is what `format:
regex` asserts. Compiling under Java is not enough on its own: Java accepts
`(?i)`, `\a` and refuses `(?#comment)` for reasons of its own.
sourceraw docstring

pattern-ofclj

p translated and compiled, memoized: patternProperties matches the same handful of patterns against every property name of every instance.

`p` translated and compiled, memoized: `patternProperties` matches the same
handful of patterns against every property name of every instance.
sourceraw docstring

scanclj

(scan p)

Read p once and answer {:java <pattern> :error <reason or nil>}.

:java is always the closest java.util.regex spelling, so a pattern Java accepts still compiles even when ECMAScript would have refused it; :error is the first reason it was not an ECMAScript pattern, which is the whole judgement format: regex makes.

Read `p` once and answer `{:java <pattern> :error <reason or nil>}`.

`:java` is always the closest java.util.regex spelling, so a pattern Java
accepts still compiles even when ECMAScript would have refused it; `:error`
is the first reason it was not an ECMAScript pattern, which is the whole
judgement `format: regex` makes.
sourceraw docstring

translateclj

(translate p)

The java.util.regex spelling of the ECMAScript pattern p.

The java.util.regex spelling of the ECMAScript pattern `p`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close