將匹配正則表達式 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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
