-1

I came across the code below and I am wondering what the small circle/degree sign means. The code is supposed to extract text between Item 1A and Item B. Thank you!

(?s)(?i)°Item 1A.*?°Item
Claire Cui
  • 107
  • 10
  • 2
    Isn't it part of the string to match? what is the input string for this regex? – Jean-François Fabre Dec 22 '17 at 20:20
  • 1
    Not a duplicate. Nothing in the referenced duplicate describes `°`. – Robᵩ Dec 22 '17 at 20:25
  • 1
    And to answer in a comment, `°` is treated as a literal character. I presume the input language uses it as a bullet marking the items. – Robᵩ Dec 22 '17 at 20:26
  • @Robᵩ I'm pretty sure it's part of the string to match itself. I don't see how non-ASCII (32-127) chars would be a part of the special regex chars. I agree it's not a duplicate. but since it's part of the string to match, it's just "unclear" or sth like that. – Jean-François Fabre Dec 22 '17 at 20:26
  • 1
    It is not part of the [regular expression syntax](https://docs.python.org/3/library/re.html#regular-expression-syntax). – Galen Dec 22 '17 at 20:29
  • Thank you all! Sorry, I do not have the string. Your answer makes the perfect sense. – Claire Cui Dec 23 '17 at 07:11

1 Answers1

0

The degree symbol, ° is treated as a literal character to be matched. Your input probably looks like this:

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

So your regular expression starts its match at °Item1A and continues through the first subsequent °Item.

Robᵩ
  • 163,533
  • 20
  • 239
  • 308