PHP Developers Network
http://forums.devnetwork.net/

HTTP regex
http://forums.devnetwork.net/viewtopic.php?f=38&t=140695
Page 1 of 1

Author:  alangueu [ Thu Dec 04, 2014 12:37 pm ]
Post subject:  HTTP regex

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

Author:  requinix [ Thu Dec 04, 2014 2:01 pm ]
Post subject:  Re: HTTP regex

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.

Author:  alangueu [ Thu Dec 04, 2014 2:18 pm ]
Post subject:  Re: HTTP regex

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

Author:  requinix [ Thu Dec 04, 2014 4:52 pm ]
Post subject:  Re: HTTP regex

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?

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/