Ananda
Ananda

Reputation: 1572

Regular expression to get specific part of request parameter from Log entry?

I have request parameter in the following format

"POST /upload/sendData.htm HTTP/1.1" 

And I want to extract resource name from that which in this case is upload/sendData.htm

Any pointers on how to do this as in some cases the request comes like

"POST //upload/sendData.htm HTTP/1.1" 

or

"POST ///upload/sendData.htm HTTP/1.1" 

I am using Java

Upvotes: 0

Views: 94

Answers (3)

Kevin Fegan
Kevin Fegan

Reputation: 1290

Try this:

"/POST[ ]+\/+([^\/].+[^ ])[ ]+HTTP/"

Upvotes: 0

Brian Stephens
Brian Stephens

Reputation: 5271

Use this:

"^POST /+(.+) HTTP/1\.1$"

Upvotes: 0

Just a guess, but is this what you're looking for?

POST \/+(\w+\/\w+.\w+)

http://rubular.com/r/IUlIH9LDzS


or maybe this

POST \/+(.+)\s

http://rubular.com/r/sdw51Ek1Wi

Upvotes: 2

Related Questions