Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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 assertRegexpMatches吗_Python_Regex_Debugging - Fatal编程技术网

需要重新审视Python assertRegexpMatches吗

需要重新审视Python assertRegexpMatches吗,python,regex,debugging,Python,Regex,Debugging,我使用的正则表达式是: ur"^[\s\S]*Ticket Price (including £0.50 booking fees)[\s\S]£5.50[\s\S]*$" 我比较的字符串是: "Ticket Price (including £0.50 booking fees) £5.50" 我已经在regex101.com上玩过了,但没用。对我来说,逻辑似乎是正确的,但它们不匹配(我试图使用assertRegexpMatches()测试代码)。任何帮助或提示都将不胜感激。您需要避免妄想

我使用的正则表达式是:

ur"^[\s\S]*Ticket Price (including £0.50 booking fees)[\s\S]£5.50[\s\S]*$"
我比较的字符串是:

"Ticket Price (including £0.50 booking fees) £5.50"

我已经在regex101.com上玩过了,但没用。对我来说,逻辑似乎是正确的,但它们不匹配(我试图使用assertRegexpMatches()测试代码)。任何帮助或提示都将不胜感激。

您需要避免妄想症和小数点。在regex
(..)
中,称为捕获组,用于捕获字符。要匹配literal
括号,必须在正则表达式中转义它们

ur"^[\s\S]*Ticket Price \(including £0\.50 booking fees\)[\s\S]£5\.50[\s\S]*$"

退出
。。否则你会有一群人谢谢你,阿维纳什。点应该可以接受任何字符,但是(我想),为什么它们不能工作呢?因为点将匹配文字点。