chickadee » regex-literals » read-regex-literal

read-regex-literal #!optional PORTprocedure

Reads a regular expression literal of the form #/.../ from PORT, which defaults to the value of (current-input-port). The literal is converted to a precompiled regular expression object using the (regexp) procedure provided by the regex unit.

Regular expression literals may include one or more options that modify the way the pattern matches strings. The options are one or more characters placed immediately after the terminator:

  • #/.../i PCRE_CASELESS: case-insensitive mode; the pattern match will ignore the case of letters in the pattern.
  • #/.../x PCRE_EXTENDED: extended mode; complex regular expressions can be difficult to read, so this option allows you to insert spaces, newlines, and comments in the pattern to make it more readable.
  • #/.../u PCRE_UTF8: UTF-8 mode; sets the language encoding of the regular expression.