Skip to content

Support regular expression literals (/pattern/flags) #35

@memburg

Description

@memburg

Summary

Add support for regex literal syntax (/pattern/flags) and a basic RegExp runtime.

Motivation

The runtime already has String.prototype.match, matchAll, replace, replaceAll, split, and search that accept string patterns. Adding /pattern/flags literals and a RegExp object would let users write regex naturally and is essential for compatibility with most non-trivial JS code.

Scope

  • Lexer: parse /pattern/flags as a regex token
  • AST node for regex literals
  • RegExp constructor and test() method
  • RegExp.prototype.exec()
  • Support flags: g, i, m, s, u
  • Wire up existing string methods to accept RegExp objects in addition to strings

Out of scope

  • RegExp lookbehind/lookahead
  • Unicode property escapes
  • String.prototype.matchAll returning an iterator (it exists as a basic implementation)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions