1

I'm trying to match jpeg images in HTTP GET requests.

For example in :

GET /category/catpic.jpg HTTP/1.1

the Regex should return : catpic

I managed to get a RegEx in Perl syntax that works fine :

/(?<=\/)[^(\/)]+(?=(\.jpg HTTP))/g

but I just don't know enough about Python to convert it to Perl syntax.

  • Can anyone help me convert this Perl RegEx in a Python RegEx ?

Thank you in advance !

EDIT: Sorry, I explained it wrong. I want to match ANY .jpg image in a HTTP GET request.

1
  • It's the same regex, just a different programming approach. Commented Jul 19, 2012 at 14:15

2 Answers 2

2

Just put what's between the slashes in Perl into a raw string r"(?<=\/)[^(\/)]+(?=(\.jpg HTTP))" and pass it to the appropriate function in the re module.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you a lot ! I will mark the question as answered in 2 min.
0

use this regex (?<=category/)(.+?)(?=\.jpg HTTP)

1 Comment

This doesn't do the same thing as the Perl regexp. Why are you looking for category specifically?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.