Page 1 of 1

HTTP regex

Posted: Thu Dec 04, 2014 11:37 am
by alangueu
hello members, I am a new regex student and it is very challenging to me I have a very important question to ask about regex.
I am actively looking for an answer about this please help me
Thanks


Please verify that the following regex will correctly test that the input data is a well-formed HTTP request.

"(?i)\\A(\\x20|\\t)*(([A-Z]|[A-Z]-?|[A-Z]_?){2,19}[A-Z])(\\x20|\\t)++.+(\\x20|\\t)++HTTP\\x2F1\\x2E(0|1)(\\x20|\\t)*"

What are its limitations?


Alain

Re: HTTP regex

Posted: Thu Dec 04, 2014 1:01 pm
by requinix
Protip: use single quotes for regex strings so you don't have to escape all those backslashes.

"Correctly" according to what? It doesn't follow the RFC, if that's what you're asking. 2616 if you want to check it out - start at section 5.1.

Re: HTTP regex

Posted: Thu Dec 04, 2014 1:18 pm
by alangueu
Hello requinix,

Thanks for your reply, i read about rfc2616 section 5.1. but not understood it
I need to:
verify that the following regex will correctly test that the input data is a well-formed HTTP request.
"(?i)\\A(\\x20|\\t)*(([A-Z]|[A-Z]-?|[A-Z]_?){2,19}[A-Z])(\\x20|\\t)++.+(\\x20|\\t)++HTTP\\x2F1\\x2E(0|1)(\\x20|\\t)*"
and what are the limitations

Re: HTTP regex

Posted: Thu Dec 04, 2014 3:52 pm
by requinix
Then let me quote myself:
requinix wrote:"Correctly" according to what? It doesn't follow the RFC, if that's what you're asking.
As far as I'm concerned, no it does not do it correctly, and its limitations are all to do with the fact that it is incorrect.

Maybe you're looking for an explanation of how the regex works?