damccorm commented on code in PR #40399:
URL: https://github.com/apache/beam/pull/40399#discussion_r4196021746
##########
sdks/python/apache_beam/transforms/util.py:
##########
@@ -2214,14 +2214,16 @@ def _process(element):
@staticmethod
@typehints.with_input_types(str)
- @typehints.with_output_types(Union[list[str], list[tuple[str, str]]])
+ @typehints.with_output_types(Union[list[str], list[tuple[str, ...]]])
@ptransform_fn
def find_all(pcoll, regex, group=0, outputEmpty=True):
"""
Returns the matches if a portion of the line matches the Regex. By default,
list of group 0 will return with empty items. To get all groups, pass the
`Regex.ALL` flag in the `group` parameter which returns all the groups in
- the tuple format.
+ the tuple format. With `Regex.ALL` each item is
+ `(match, group1, group2, ...)`, and `outputEmpty=False` drops an item only
+ when the whole match is empty, the same as for group 0.
Review Comment:
```suggestion
the tuple format. When using `Regex.ALL`, each item is formatted as a
tuple: `(match, group1, group2, ...)`.
```
##########
sdks/python/apache_beam/transforms/util.py:
##########
Review Comment:
```suggestion
outputEmpty: (optional) Whether to allow matches with empty groups.
If false, these outputs will be silently dropped.
```
##########
CHANGES.md:
##########
@@ -74,7 +74,7 @@
## Breaking Changes
-* X behavior was changed ([#X](https://github.com/apache/beam/issues/X)).
+* (Python) `Regex.find_all` with `group=Regex.ALL` now returns every group, as
`(match, group1, group2, ...)`, instead of only group 1, and with
`outputEmpty=False` it drops a match only when the whole match is empty, the
same as `group=0` ([#40399](https://github.com/apache/beam/pull/40399)).
Review Comment:
```suggestion
* (Python) `Regex.find_all` with `group=Regex.ALL` now returns every group,
as `(match, group1, group2, ...)`, instead of only group 1, and with
`outputEmpty=False` it drops a match only when the whole match is empty,
matching the `group=0` behavior
([#40399](https://github.com/apache/beam/pull/40399)).
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]