You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
regex adds he regex.Match.captures() method for returning a list of all captures that a capture-group makes. regex.Match.captures(N) returns the list of captures for group N just as re.Match.group(N) return the last capture. regex.Match.captures() returns the list of captures for group 0 just as re.Match.group()
re also has re.Match.groups() that returns a tuple of all last captures.
But regex has no way to easily return the same information. ie a tuple of lists of all captures.
m2=regex.fullmatch(ip_regex, ip)
# nothing can go here to imitate print(f"{m1.groups()=}")print(f"{m2.captures()=}")
print(f"{m2.captures(0)=}")
print(f"{m2.captures(1)=}")
print(f"{m2.captures(2)=}")
print(f"{m2.captures(3)=}")
One possibility would be to rename regex.Match.captures() to regex.Match.capture() to match the name of re.Match.group()
Then use regex.Match.captures() to match the name of re.Match.groups()
This would obviously be a breaking change
so alternatively adding a new method eg. regex.Match.capturestuple() named similar to regex.Match.capturesdict()
The text was updated successfully, but these errors were encountered:
regex
adds heregex.Match.captures()
method for returning a list of all captures that a capture-group makes.regex.Match.captures(N)
returns the list of captures for groupN
just asre.Match.group(N)
return the last capture.regex.Match.captures()
returns the list of captures for group0
just asre.Match.group()
re
also hasre.Match.groups()
that returns a tuple of all last captures.But
regex
has no way to easily return the same information. ie a tuple of lists of all captures.Given the following example:
One possibility would be to rename
regex.Match.captures()
toregex.Match.capture()
to match the name ofre.Match.group()
Then use
regex.Match.captures()
to match the name ofre.Match.groups()
This would obviously be a breaking change
so alternatively adding a new method eg.
regex.Match.capturestuple()
named similar toregex.Match.capturesdict()
The text was updated successfully, but these errors were encountered: