dataiter.regex¶
The regex module contains vectorized versions of regular expression matching
operations, similar to numpy.strings for string operations. This is a
convenience wrapper around Python’s standard library re module, not any
efficient reimplementation.
findall()
fullmatch()
match()
search()
split()
sub()
subn()
- dataiter.regex.findall(pattern, string, flags=0)[source]¶
Return a list of matches of pattern in string.
https://docs.python.org/3/library/re.html#re.findall
>>> x = di.Vector(["asdf", "1234"]) >>> regex.findall(r"[a-z]", x) [ ['a', 's', 'd', 'f'] [] ] object
- dataiter.regex.fullmatch(pattern, string, flags=0)[source]¶
Return a
re.Matchobject orNone.https://docs.python.org/3/library/re.html#re.fullmatch
>>> x = di.Vector(["asdf", "1234"]) >>> regex.fullmatch(r"[a-z]+", x) [ <re.Match object; span=(0, 4), match='asdf'> None ] object
- dataiter.regex.match(pattern, string, flags=0)[source]¶
Return a
re.Matchobject orNone.https://docs.python.org/3/library/re.html#re.match
>>> x = di.Vector(["asdf", "1234"]) >>> regex.match(r"[a-z]", x) [ <re.Match object; span=(0, 1), match='a'> None ] object
- dataiter.regex.search(pattern, string, flags=0)[source]¶
Return a
re.Matchobject orNone.https://docs.python.org/3/library/re.html#re.search
>>> x = di.Vector(["asdf", "1234"]) >>> regex.search(r"[a-z]", x) [ <re.Match object; span=(0, 1), match='a'> None ] object
- dataiter.regex.split(pattern, string, maxsplit=0, flags=0)[source]¶
Return a list of string split by pattern.
https://docs.python.org/3/library/re.html#re.split
>>> x = di.Vector(["one two three", "four"]) >>> regex.split(r" +", x) [ ['one', 'two', 'three'] ['four'] ] object
- dataiter.regex.sub(pattern, repl, string, count=0, flags=0)[source]¶
Return string with instances of pattern replaced with repl.
https://docs.python.org/3/library/re.html#re.sub
>>> x = di.Vector(["great", "fantastic"]) >>> regex.sub(r"$", r"!", x) [ "great!" "fantastic!" ] string
- dataiter.regex.subn(pattern, repl, string, count=0, flags=0)[source]¶
Return string, count of instances of pattern replaced with repl.
https://docs.python.org/3/library/re.html#re.subn
>>> x = di.Vector(["great", "fantastic"]) >>> regex.subn(r"$", r"!", x) [ ('great!', 1) ('fantastic!', 1) ] object