python正则表达式度标志

时间:2017-12-22 20:14:04

标签: python regex

我遇到了下面的代码,我想知道小圆圈/度数标志意味着什么。该代码应该在项目1A和项目B之间提取文本。谢谢!

(?s)(?i)°Item 1A.*?°Item

1 个答案:

答案 0 :(得分:0)

度数符号°被视为要匹配的文字字符。您的输入可能如下所示:

°Item 1A: Giraffes. Girrafes are taller than anteaters.
°Item 1B: Elephants. Elephants are taller than anteaters.
°Item 1C: Ants. Ants are shorter than anteaters.

因此,您的正则表达式会在°Item1A处开始匹配并继续第一个°Item