On this page:
rx/  range-operator
char>=/  c
rx/  range
rx/  ranges
rx/  range?
rx/  match
rx/  match?
rx/  not-match-operator
rx/  not-match
rx/  ^match
rx/  not-match?
rx/  match-range
rx/  not-match-range
rx/  ^match-range
rx/  escape
3.1 Named Ranges
rx/  range-lower
rx/  match-lower
rx/  range-upper
rx/  match-upper
rx/  range-alpha
rx/  match-alpha
rx/  range-digit
rx/  match-digit
rx/  range-alnum
rx/  match-alnum
rx/  range-xdigit
rx/  match-xdigit
rx/  range-word
rx/  match-word

3 Match and Range🔗ℹ

A range expression is specified as char1 - char2, where all characters between the first and second character are considered, inclusively. A match expression is a set of characters, ranges, where any member of the set matches.

The range operator is the - in char1 - char2.

value

char>=/c : contract?

A contract used in rx/range which ensures the second parameter is greater than, or equal to, the first.

procedure

(rx/range from to)  string?

  from : char?
  to : (and/c char? (char>=/c from))
Create a character range including all characters in from ... to.

Examples:
> (rx/range #\A #\F)

"A-F"

> (rx/range #\F #\A)

to-char: contract violation

  expected: char>=? #\F

  given: #\A

procedure

(rx/ranges from ...+)  string?

  from : (cons/c char? char?)
Create multiple rx/ranges at the same time.

Example:
> (rx/ranges '(#\A . #\F) '(#\F . #\A))

to-char: contract violation

  expected: char>=? #\F

  given: #\A

procedure

(rx/range? expr)  boolean?

  expr : string?
A predicate that returns true if expr is a valid range string.

procedure

(rx/match expr ...)  string?

  expr : (or/c char? string?)
Create a match expression that matches any character specified in the match set. The set can be denoted as single char?s, single-character string?s, or unbounded strings.

Examples:
> (rx/match "a" "b" "cd")

"[abcd]"

> (rx/match #\a #\b "cd")

"[abcd]"

procedure

(rx/match? expr)  boolean?

  expr : string?
A predicate that returns true if expr is a valid match string.

The string used as an operator to negate a match expression.

procedure

(rx/not-match expr ...)  string?

  expr : string?

procedure

(rx/^match expr ...)  string?

  expr : string?
Create a negated match expression that matches any character not specified in the match set.

Examples:
> (rx/not-match "a" "b" "cd")

"[^abcd]"

> (rx/^match "a" "b" "cd")

"[^abcd]"

procedure

(rx/not-match? expr)  boolean?

  expr : string?
A predicate that returns true if expr is a valid negated match string.

procedure

(rx/match-range from to)  string?

  from : char?
  to : char?
Create a match expression which matches the range of characters in from ... to.

Examples:
> (rx/match-range #\x #\z)

"[x-z]"

> ((compose rx/match rx/range) #\x #\z)

"[x-z]"

procedure

(rx/not-match-range from to)  string?

  from : char?
  to : char?

procedure

(rx/^match-range from to)  string?

  from : char?
  to : char?
Create a match expression which matches any character except those in from ... to.

Examples:
> (rx/not-match-range #\g #\p)

"[^g-p]"

> (rx/^match-range #\g #\p)

"[^g-p]"

procedure

(rx/escape val [location])  string?

  val : (or/c char? string?)
  location : (or/c 'in-match 'outside-match) = 'in-match
TBD

Examples:
> (rx/escape "-")

"\\-"

> (rx/escape "|")

"|"

> (rx/escape "-" 'outside-match)

"-"

> (rx/escape "|" 'outside-match)

"\\|"

3.1 Named Ranges🔗ℹ

A pre-defined range, and match, for ASCII lower-case letter characters. Equivalent to [a-z].

A pre-defined range, and match, for ASCII upper-case letter characters. Equivalent to [A-Z].

A pre-defined range, and match, for ASCII upper-case and lower-case letter characters. Equivalent to [A-Za-z].

A pre-defined range, and match, for ASCII decimal digit characters. Equivalent to [0-9].

A pre-defined range, and match, for ASCII alpha-numeric characters. Equivalent to [A-Za-z0-9].

A pre-defined range, and match, for ASCII hex digit characters. Equivalent to [0-9A-Fa-f].

A pre-defined range, and match, for ASCII word characters. Equivalent to [A-Fa-f0-9_].