-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6c4b4a
commit f37e289
Showing
8 changed files
with
825 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from ..EZRegex import EZRegex | ||
|
||
|
||
class REZRegex(EZRegex): | ||
_escape_chars=b'()[]{}?*+-|^$\\.&~# ' | ||
_end = '' | ||
_beginning = '' | ||
|
||
def _flag_func(self, final): | ||
return f'(?{self.flags}){final}' | ||
|
||
def _final_func(self, s:str) -> str: | ||
return s.replace('\\', '\\\\') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
""" Support for the Perl dialect of regular expressions""" | ||
__version__ = '0.0.1' | ||
|
||
from .elements import * | ||
from .REZRegex import REZRegex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# pyright: reportArgumentType = false | ||
# pyright: reportUndefinedVariable = false | ||
from ..base import load_base | ||
from ..EZRegex import EZRegex | ||
from .REZRegex import REZRegex | ||
|
||
globals().update(load_base(REZRegex, lambda num_or_name, cur=...: fr'{cur}\g{{{num_or_name}}}')) | ||
|
||
# I can't figure out how flags work in R, so I'm just ignoring them | ||
del line_starts_with | ||
del lineStartsWith | ||
del line_start | ||
del lineStart | ||
del line_ends_with | ||
del lineEndsWith | ||
del line_end | ||
del lineEnd | ||
|
||
del ASCII | ||
del DOTALL | ||
del IGNORECASE | ||
del LOCALE | ||
del MULTILINE | ||
del UNICODE | ||
|
||
# Matches any single character except line break characters, like the dot, but is not affected by any options that make the dot match all characters including line breaks. | ||
not_newline = REZRegex(r'\N') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from .REZRegex import REZRegex | ||
from ..base.interface import * | ||
|
||
# I can't figure out how flags work in R, so I'm just ignoring them | ||
del line_starts_with | ||
del lineStartsWith | ||
del line_start | ||
del lineStart | ||
del line_ends_with | ||
del lineEndsWith | ||
del line_end | ||
del lineEnd | ||
|
||
del ASCII | ||
del DOTALL | ||
del IGNORECASE | ||
del LOCALE | ||
del MULTILINE | ||
del UNICODE | ||
|
||
"Group: Not Literals" | ||
not_newline: REZRegex = REZRegex(r'\N') | ||
'Matches any single character except line break characters, like the dot, but is not affected by any options that make the dot match all characters including line breaks.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import jstyleson | ||
from ezregex.R import * | ||
from ezregex import EZRegex, R | ||
|
||
|
||
def test_R(): | ||
print(word + group(digit + '45') + raw('\\w+')) | ||
assert str(word + group(digit + '45') + raw('\\w+')) == r'\\w+(\\d45)\\w+' |