Skip to content

Commit ba1d7ba

Browse files
committed
Add the 'with_ascii' modifier to fix a python 3 compatibility, according to #21 pr
1 parent cc5060c commit ba1d7ba

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

verbalexpressions/verbal_expressions.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class VerEx(object):
2424
'''
2525
def __init__(self):
2626
self.s = []
27-
self.modifiers = {'I': 0, 'M': 0}
27+
self.modifiers = {'I': 0, 'M': 0, 'A': 0}
2828

2929
def __getattr__(self, attr):
3030
''' any other function will be sent to the regex object '''
@@ -43,7 +43,10 @@ def add(self, value):
4343

4444
def regex(self):
4545
''' get a regular expression object. '''
46-
return re.compile(str(self), self.modifiers['I'] | self.modifiers['M'])
46+
return re.compile(
47+
str(self),
48+
self.modifiers['I'] | self.modifiers['M'] | self.modifiers['A']
49+
)
4750
compile = regex
4851

4952
def source(self):
@@ -117,3 +120,7 @@ def with_any_case(self, value=False):
117120
def search_one_line(self, value=False):
118121
self.modifiers['M'] = re.M if value else 0
119122
return self
123+
124+
def with_ascii(self, value=False):
125+
self.modifiers['A'] = re.A if value else 0
126+
return self

0 commit comments

Comments
 (0)