RegexPattern
Represents a combinator structure for building more complex regexes
It might be worth working with this combinator structure in a _lazy_ fashion so that we can drill down
into the expression structure... that way we can define a sort-of Regex calculus that we can use to build up higher
order regexes but still be able to recursively inspect subparts?
Properties and Methods
__init__(self, pat, name=None, children=None, parents=None, dtype=None, repetitions=None, key=None, joiner='', join_function=None, wrapper_function=None, suffix=None, prefix=None, parser=None, handler=None, default_value=None, capturing=None, allow_inner_captures=False):
pat
:str | callable
No description…
name
:str
No description…
dtype
:Any
No description…
repetitions
:Any
No description…
key
:Any
No description…
joiner
:Any
No description…
children
:Any
No description…
parents
:Any
No description…
wrapper_function
:Any
No description…
suffix
:Any
No description…
prefix
:Any
No description…
parser
:Any
No description…
handler
:Any
No description…
capturing
:Any
No description…
allow_inner_captures
:Any
No description…
@property
pat(self):
@property
children(self):
:returns
:tuple[RegexPattern]
No description…
@property
child_count(self):
:returns
:int
No description…
@property
child_map(self):
Returns the map to subregexes for named regex components
:returns
:Dict[str, RegexPattern]
No description…
@property
parents(self):
:returns
:tuple[RegexPattern]
No description…
@property
joiner(self):
:returns
:str
No description…
@property
join_function(self):
:returns
:function
No description…
@property
suffix(self):
:returns
:str | RegexPattern
No description…
@property
prefix(self):
:returns
:str | RegexPattern
No description…
@property
dtype(self):
Returns the StructuredType for the matched object
The basic thing we do is build the type from the contained child dtypes
The process effectively works like this:
If there's a single object, we use its dtype no matter what
Otherwise, we add together our type objects one by one, allowing the StructuredType to handle the calculus
After we've built our raw types, we compute the shape on top of these, using the assigned repetitions object
One thing I realize now I failed to do is to include the effects of sub-repetitions... only a single one will
ever get called. - `:returns`: `None | StructuredType`
>No description...
@property
is_repeating(self):
@property
capturing(self):
get_capturing_groups(self, allow_inners=None):
We walk down the tree to find the children with capturing groups in them and then find the outermost RegexPattern for those unless allow_inners is on in which case we pull them all
@property
captures(self):
Subtly different from capturing n that it will tell us if we need to use the group in post-processing, essentially
:returns
:_
No description…
@property
capturing_groups(self):
Returns the capturing children for the pattern
:returns
:_
No description…
@property
named_groups(self):
Returns the named children for the pattern
:returns
:_
No description…
combine(self, other, *args, **kwargs):
Combines self and other
other
:RegexPattern | str
No description…
:returns
:str | callable
No description…
wrap(self, *args, **kwargs):
build(self, joiner=None, prefix=None, suffix=None, recompile=True, no_captures=False, verbose=False):
@property
compiled(self):
add_parent(self, parent):
remove_parent(self, parent):
add_child(self, child):
add_children(self, children):
remove_child(self, child):
insert_child(self, index, child):
invalidate_cache(self):
__copy__(self):
__add__(self, other):
Combines self and other
other
:RegexPattern
No description…
:returns
:_
No description…
__radd__(self, other):
Combines self and other
other
:RegexPattern
No description…
:returns
:_
No description…
__call__(self, other, *args, name=None, dtype=None, repetitions=None, key=None, joiner=None, join_function=None, wrap_function=None, suffix=None, prefix=None, multiline=None, parser=None, handler=None, capturing=None, default=None, allow_inner_captures=None, **kwargs):
Wraps self around other
other
:RegexPattern
No description…
:returns
:_
No description…
__repr__(self):
__str__(self):
__getitem__(self, item):
match(self, txt):
search(self, txt):
findall(self, txt):
finditer(self, txt):
Examples
Edit Examples or
Create New Examples
Edit Template or
Create New Template
Edit Docstrings