将匹配正则表达式 pattern 的 input 的元素替换为 rewrite 。
用法
tf.strings.regex_replace(
input, pattern, rewrite, replace_global=True, name=None
)参数
-
inputstringTensor,要处理的源字符串。 -
pattern字符串或标量字符串Tensor,要使用的正则表达式,请参阅更多详细信息https://github.com/google/re2/wiki/Syntax -
rewrite字符串或标量字符串Tensor,用于匹配替换的值,支持 backslash-escaped 数字(\1 到 \9)可以插入匹配相应括号组的文本。 -
replace_globalbool,如果True替换所有不重叠的匹配项,否则仅替换第一个匹配项。 -
name操作的名称(可选)。
返回
-
字符串
Tensor的形状与input相同,并带有指定的替换。
tf.strings.regex_replace("Text with tags.<br /><b>contains html</b>",
"<[^>]+>", " ")
<tf.Tensor:shape=(), dtype=string, numpy=b'Text with tags. contains html '>
相关用法
- Python tf.strings.regex_full_match用法及代码示例
- Python tf.strings.reduce_join用法及代码示例
- Python tf.strings.substr用法及代码示例
- Python tf.strings.length用法及代码示例
- Python tf.strings.bytes_split用法及代码示例
- Python tf.strings.as_string用法及代码示例
- Python tf.strings.unsorted_segment_join用法及代码示例
- Python tf.strings.lower用法及代码示例
- Python tf.strings.split用法及代码示例
- Python tf.strings.upper用法及代码示例
- Python tf.strings.unicode_decode_with_offsets用法及代码示例
- Python tf.strings.join用法及代码示例
- Python tf.strings.to_hash_bucket用法及代码示例
- Python tf.strings.ngrams用法及代码示例
- Python tf.strings.to_hash_bucket_strong用法及代码示例
- Python tf.strings.unicode_decode用法及代码示例
- Python tf.strings.unicode_encode用法及代码示例
- Python tf.strings.format用法及代码示例
- Python tf.strings.to_hash_bucket_fast用法及代码示例
- Python tf.strings.to_number用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.strings.regex_replace。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
