lasante23 - 11 months ago 47
Python Question

# Match number between '<<' (regex)

I have the following string

All files | 100 <<222>>

And would like to match the number between
<< >>

How can I do that?

So far I tried this expression
(?<<)(.*?)(?>>)

The problem is, that < is a special character, which needs to be escaped. Also, the ? in the first and third group are invalid:
(\<\<)(?P<number>\d*?)(\>\>)

Additionally, I named the group with the number and used \d to match digits instead of *. I tested it here.