Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何通过搜索识别文本中的括号?_Python_Regex - Fatal编程技术网

Python 如何通过搜索识别文本中的括号?

Python 如何通过搜索识别文本中的括号?,python,regex,Python,Regex,例如,我试图检查以下子字符串 x先生(“CEO”) 在 X先生(“CEO”)去了华盛顿 使用 不幸的是,re.search返回无re.search(re.escape(“X先生(“CEO”)),“X先生(“CEO”)去了华盛顿”),包括re.escape非常感谢 re.search('Mr. X ("CEO")','Mr. X ("CEO") went to Washington')

例如,我试图检查以下子字符串 x先生(“CEO”) 在 X先生(“CEO”)去了华盛顿

使用


不幸的是,re.search返回无

re.search(re.escape(“X先生(“CEO”)),“X先生(“CEO”)去了华盛顿”)
,包括
re.escape
非常感谢
re.search('Mr. X ("CEO")','Mr. X ("CEO") went to Washington')