2022-06-22 10:46:33 +08:00
|
|
|
|
mindspore.dataset.text.RegexReplace
|
|
|
|
|
|
===================================
|
2022-02-14 14:34:37 +08:00
|
|
|
|
|
2022-06-22 10:46:33 +08:00
|
|
|
|
.. py:class:: mindspore.dataset.text.RegexReplace(pattern, replace, replace_all=True)
|
2022-02-14 14:34:37 +08:00
|
|
|
|
|
|
|
|
|
|
根据正则表达式对UTF-8编码格式的字符串内容进行正则替换。
|
|
|
|
|
|
|
|
|
|
|
|
有关支持的正则表达式的模式,请参阅 https://unicode-org.github.io/icu/userguide/strings/regexp.html。
|
|
|
|
|
|
|
2022-03-26 21:10:33 +08:00
|
|
|
|
.. note:: Windows平台尚不支持 `RegexReplace` 。
|
2022-02-14 14:34:37 +08:00
|
|
|
|
|
2022-07-08 16:45:20 +08:00
|
|
|
|
参数:
|
|
|
|
|
|
- **pattern** (str) - 正则表达式的模式。
|
|
|
|
|
|
- **replace** (str) - 替换匹配元素的字符串。
|
|
|
|
|
|
- **replace_all** (bool, 可选) - 如果为False,只替换第一个匹配的元素; 如果为True,则替换所有匹配的元素。默认值:True。
|
|
|
|
|
|
|
|
|
|
|
|
异常:
|
|
|
|
|
|
- **TypeError** - 参数 `pattern` 的类型不是str。
|
|
|
|
|
|
- **TypeError** - 参数 `replace` 的类型不是str。
|
|
|
|
|
|
- **TypeError** - 参数 `replace_all` 的类型不是bool。
|