crandas.re

Regular expression matching

See: String search and regular expressions

class crandas.re.Re(expr)

Bases: object

Represents a regular expression for use with crandas.

Can be used as an argument to CSeries.fullmatch().

Constructed from a string representing the regular expression. Supported operators:

  • |: union

  • *: Kleene star (zero or or more)

  • +: one or more

  • ?: zero or one

  • .: any character (note that this also matches non-printable characters)

  • (, ): regexp grouping

  • [...]: set of characters (including character ranges, e.g., [A-Za-z])

  • \d: digits (equivalent to [0-9])

  • \s: whitespace (equivalent to [\\ \t\n\r\f\v])

  • \w: alphanumeric and underscore (equivalent to [a-zA-Z0-9_])

  • (?1), (?2), …: substring (given as additional argument to CSeries.fullmatch())

Note that bounded repetitions, e.g., [a-z]{0,3} are not currently supported.

Internally, this class is based on PythonRegex from pyformlang. For more details, see here and here.

Parameters:

expr (str) – Regular expression (see above)