Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Measure memory / performance if regexes are compiled in ASCII mode #212

Copy link
Copy link
Closed
@masklinn

Description

@masklinn
Issue body actions

Per https://docs.python.org/3/library/re.html:

  • \d Matches any Unicode decimal digit (that is, any character in Unicode character category [Nd]). This includes [0-9], and also many other digit characters.
  • \w Matches Unicode word characters; this includes all Unicode alphanumeric characters (as defined by str.isalnum()), as well as the underscore (_).

However according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes (which given the reference implementation is in JS is likely the implicit reference semantics)

  • \d Digit character class escape: Matches any digit (Arabic numeral). Equivalent to [0-9]. For example, /\d/ or /[0-9]/ matches "2" in "B2 is the suite number".
  • \w Word character class escape: Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to [A-Za-z0-9_]. For example, /\w/ matches "a" in "apple", "5" in "$5.28", "3" in "3D" and "m" in "Émanuel".

This corresponds to the re.ASCII versions of the Python regexes:

  • \d Matches [0-9] if the ASCII flag is used.
  • \w Matches [a-zA-Z0-9_] if the ASCII flag is used.

This might do nothing (because regex uses library means to check those classes) or it might reduce the amount of state the regex needs to store.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.