Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Module] Add re module for easy regular expressions operations #266

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

khchen
Copy link

@khchen khchen commented Jun 26, 2022

This re module is based on a modified pike vm and have following features:

  1. Lightweight (about 15~20k only, depend on compile flags).
  2. Support almost all common RE pattern and group capture (except backreferences).
  3. Guarantees that any input regex will scale O(n) with the size of the string.
  4. Support global mode and case insensitive mode.
  5. Support UTF8.

Example:

print(re.match('\\d', 'a1b2c3d4'))
print(re.match('\\d', 'a1b2c3d4', re.G))
print(re.test('[馃榾-馃槅]', '馃榿'))
print(re.test('[馃榾-馃槅]', '馃懟'))
print(re.split('\\d', 'a1b2c3d'))

Output:

["1"]
["1", "2", "3", "4"]
true
false
["a", "b", "c", "d"]

  - utf8 and almost all regex pattern are supported
  - guarantees that any input regex will scale O(n) with the size of the string
* re.replace can accept a closure for string substitute.
* complete test suite.
@khchen khchen changed the title Add re module for easy regular expressions operations [Enhancement] Add re module for easy regular expressions operations Jul 18, 2022
@khchen khchen changed the title [Enhancement] Add re module for easy regular expressions operations [Module] Add re module for easy regular expressions operations Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant