删除字符串中括号及其中的内容。 包括括号 () 和中文括号()。 :param line: 原始字符串 :return: 删除括号内容后的字符串
(line)
| 36 | |
| 37 | def remove_text_in_brackets(input_file, output_file, strong_clean_flag = False): |
| 38 | def process(line): |
| 39 | """ |
| 40 | 删除字符串中括号及其中的内容。 |
| 41 | 包括括号 () 和中文括号()。 |
| 42 | :param line: 原始字符串 |
| 43 | :return: 删除括号内容后的字符串 |
| 44 | """ |
| 45 | # 使用正则表达式匹配括号及其中的内容 |
| 46 | # 匹配圆括号 () 或中文括号(),以及其中的内容 |
| 47 | return re.sub(r"[\(\(][^\)\)]*[\)\)]", "", line) |
| 48 | |
| 49 | def remove_non_alpha(string): |
| 50 | # 使用正则表达式删除首尾非字母字符 |
no outgoing calls
no test coverage detected