github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/replace.md (about)

     1  ### `replace()` {#fn-replace}
     2  
     3  函数原型:`fn replace(key: str, regex: str, replace_str: str)`
     4  
     5  函数说明:对指定字段上获取的字符串数据按正则进行替换
     6  
     7  函数参数
     8  
     9  - `key`: 待提取字段
    10  - `regex`: 正则表达式
    11  - `replace_str`: 替换的字符串
    12  
    13  示例:
    14  
    15  ```python
    16  # 电话号码:{"str_abc": "13789123014"}
    17  json(_, str_abc)
    18  replace(str_abc, "(1[0-9]{2})[0-9]{4}([0-9]{4})", "$1****$2")
    19  
    20  # 英文名 {"str_abc": "zhang san"}
    21  json(_, str_abc)
    22  replace(str_abc, "([a-z]*) \\w*", "$1 ***")
    23  
    24  # 身份证号 {"str_abc": "362201200005302565"}
    25  json(_, str_abc)
    26  replace(str_abc, "([1-9]{4})[0-9]{10}([0-9]{4})", "$1**********$2")
    27  
    28  # 中文名 {"str_abc": "小阿卡"}
    29  json(_, str_abc)
    30  replace(str_abc, '([\u4e00-\u9fa5])[\u4e00-\u9fa5]([\u4e00-\u9fa5])', "$1*$2")
    31  ```
    32