cudf.core.column.string.StringMethods.replace_with_backrefs#

StringMethods.replace_with_backrefs(pat: str, repl: str) SeriesOrIndex[source]#

Use the repl back-ref template to create a new string with the extracted elements found using the pat expression.

Parameters:
patstr or compiled regex

Regex with groupings to identify extract sections. This should not be a compiled regex.

replstr

String template containing back-reference indicators.

Returns:
Series/Index of str dtype

Examples

>>> import cudf
>>> s = cudf.Series(["A543","Z756"])
>>> s.str.replace_with_backrefs('(\\d)(\\d)', 'V\\2\\1')
0    AV453
1    ZV576
dtype: object