r""" Extract all matches of capture groups in the regex pat as new dimensions in a DataArray. For each string in the DataArray, extract groups from all matches of regular expression pat. Equivalent to applying re.findall() to all the elements in the DataArray
(
self,
pat: str | bytes | Pattern | Any,
group_dim: Hashable,
match_dim: Hashable,
case: bool | None = None,
flags: int = 0,
)
| 2100 | ) |
| 2101 | |
| 2102 | def extractall( |
| 2103 | self, |
| 2104 | pat: str | bytes | Pattern | Any, |
| 2105 | group_dim: Hashable, |
| 2106 | match_dim: Hashable, |
| 2107 | case: bool | None = None, |
| 2108 | flags: int = 0, |
| 2109 | ) -> T_DataArray: |
| 2110 | r""" |
| 2111 | Extract all matches of capture groups in the regex pat as new |
| 2112 | dimensions in a DataArray. |
| 2113 | |
| 2114 | For each string in the DataArray, extract groups from all matches |
| 2115 | of regular expression pat. |
| 2116 | Equivalent to applying re.findall() to all the elements in the DataArray |
| 2117 | and splitting the results across dimensions. |
| 2118 | |
| 2119 | If `pat` is array-like, it is broadcast against the array and applied |
| 2120 | elementwise. |
| 2121 | |
| 2122 | Parameters |
| 2123 | ---------- |
| 2124 | pat : str or re.Pattern |
| 2125 | A string containing a regular expression or a compiled regular |
| 2126 | expression object. If array-like, it is broadcast. |
| 2127 | group_dim : hashable |
| 2128 | Name of the new dimensions corresponding to the capture groups. |
| 2129 | This dimension is added to the new DataArray first. |
| 2130 | match_dim : hashable |
| 2131 | Name of the new dimensions corresponding to the matches for each group. |
| 2132 | This dimension is added to the new DataArray second. |
| 2133 | case : bool, default: True |
| 2134 | If True, case sensitive. |
| 2135 | Cannot be set if `pat` is a compiled regex. |
| 2136 | Equivalent to setting the `re.IGNORECASE` flag. |
| 2137 | flags : int, default: 0 |
| 2138 | Flags to pass through to the re module, e.g. `re.IGNORECASE`. |
| 2139 | see `compilation-flags <https://docs.python.org/3/howto/regex.html#compilation-flags>`_. |
| 2140 | ``0`` means no flags. Flags can be combined with the bitwise or operator ``|``. |
| 2141 | Cannot be set if `pat` is a compiled regex. |
| 2142 | |
| 2143 | Returns |
| 2144 | ------- |
| 2145 | extracted : same type as values or object array |
| 2146 | |
| 2147 | Raises |
| 2148 | ------ |
| 2149 | ValueError |
| 2150 | `pat` has no capture groups. |
| 2151 | ValueError |
| 2152 | `case` is set when `pat` is a compiled regular expression. |
| 2153 | KeyError |
| 2154 | Either of the given dimensions is already present in the DataArray. |
| 2155 | KeyError |
| 2156 | The given dimensions names are the same. |
| 2157 | |
| 2158 | Examples |
| 2159 | -------- |