Skip to content

Commit

Permalink
feat(processors): re_groups
Browse files Browse the repository at this point in the history
  • Loading branch information
zireael committed Oct 25, 2019
1 parent 9c1fa22 commit 157e481
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions acrawler/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ def _f(value):

return _f

@staticmethod
def re_groups(regex, default=None):
def _f(value):
match = re.search(regex, value)
if match:
return match.groups(default)
return None

return _f

@staticmethod
def re_groupdict(regex, default=None):
def _f(value):
match = re.search(regex, value)
if match:
return match.groupdict(default)
return None

return _f

@staticmethod
def default(default, fn=bool):
def _f(value):
Expand Down

0 comments on commit 157e481

Please sign in to comment.