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

     1  ### `replace()` {#fn-replace}
     2  
     3  Function prototype: `fn replace(key: str, regex: str, replace_str: str)`
     4  
     5  Function description: Replace the string data obtained on the specified field according to regular rules
     6  
     7  Function parameters:
     8  
     9  - `key`: the field to be extracted
    10  - `regex`: regular expression
    11  - `replace_str`: string to replace
    12  
    13  Example:
    14  
    15  ```python
    16  # Phone number: {"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  # English name {"str_abc": "zhang san"}
    21  json(_, str_abc)
    22  replace(str_abc, "([a-z]*) \\w*", "$1 ***")
    23  
    24  # ID number {"str_abc": "362201200005302565"}
    25  json(_, str_abc)
    26  replace(str_abc, "([1-9]{4})[0-9]{10}([0-9]{4})", "$1**********$2")
    27  
    28  # Chinese name {"str_abc": "Little Aka"}
    29  json(_, str_abc)
    30  replace(str_abc, '([\u4e00-\u9fa5])[\u4e00-\u9fa5]([\u4e00-\u9fa5])', "$1*$2")
    31  ```