Skip to content

Instantly share code, notes, and snippets.

@rinarakaki
Last active January 19, 2023 02:51
Show Gist options
  • Save rinarakaki/da6c1655637d58d0e8ea9600795d7af5 to your computer and use it in GitHub Desktop.
Save rinarakaki/da6c1655637d58d0e8ea9600795d7af5 to your computer and use it in GitHub Desktop.
Restricted (and not Perl compatible) Regular Expression

Rules

Quantifier

We only use [ ] as quantifier not { } like [n], [m,n]. In expression [m,n], m or n can be omitted like [,n], [m,]. And you can't use *, +, and ? as quantifier anymore (first restriction).

Star

* is used as any single character with quantifier instead of .. For example *[1]hoge matches ahoge, bhoge, choge. Without quantifier, * operates as a wildcard, which means it is interpreted as *[0,] rather than *[1], so you can express partial matches like *hoge*, hoge*(forward match) and *hoge(backward match). Now you can't express them like ^hoge and hoge$ anymore (second restriction).

Group

In turn, we use { } as group expression.

TODO User defined group

Modifier

TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment