2

I want to extract the line using regex. The line that I want to extract from document is:

":method":"POST",":path":"/api/browser/projects/8bd4d1d3-0b69-515e-8e15-e9c49992f7d5/buckets/b-ao-mock-testing/copy

The regex I am using is:

":method"[:"a-z,/\d-]{20,1000}/copy

The code for the same in python is:

re.findall('":method"[:"a-z,/\d-]{20,1000}/copy', str(s), re.MULTILINE)

It is working perfectly fine in sublime text but not in python. It is returning an empty list in python. How to resolve this?

shivank01
  • 1,015
  • 3
  • 16
  • 35
  • 1
    By default, the regex search in Sublime text is case insensitive. You need to turn on `Aa` button to make it case sensitive. In Python, you just used a different regex, without `re.I`. Use `re.I`. – Wiktor Stribiżew Apr 22 '20 at 21:14

1 Answers1

0

You need to use i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z]). Without this how will POST match?

or use ":method"[:"a-zA-Z,/\d-]{20,1000}/copy

See demo

vks
  • 67,027
  • 10
  • 91
  • 124