Skip to content

Commit

Permalink
Add the 'with_ascii' modifier to fix a python 3 compatibility, accord…
Browse files Browse the repository at this point in the history
…ing to #21 pr
  • Loading branch information
vtitor committed Jan 4, 2018
1 parent cc5060c commit ba1d7ba
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions verbalexpressions/verbal_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class VerEx(object):
'''
def __init__(self):
self.s = []
self.modifiers = {'I': 0, 'M': 0}
self.modifiers = {'I': 0, 'M': 0, 'A': 0}

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

def regex(self):
''' get a regular expression object. '''
return re.compile(str(self), self.modifiers['I'] | self.modifiers['M'])
return re.compile(
str(self),
self.modifiers['I'] | self.modifiers['M'] | self.modifiers['A']
)
compile = regex

def source(self):
Expand Down Expand Up @@ -117,3 +120,7 @@ def with_any_case(self, value=False):
def search_one_line(self, value=False):
self.modifiers['M'] = re.M if value else 0
return self

def with_ascii(self, value=False):
self.modifiers['A'] = re.A if value else 0
return self

0 comments on commit ba1d7ba

Please sign in to comment.