1

I'm using pcrecpp to match and expression in my C++ program. The relevant code is:

pcrecpp::RE("GET (\n*|.*)* HTTP").PartialMatch(packet, &getUrl);

cout << "GET " << getUrl << endl;

And the text i want to match is something like:

GET /subscribe?host_int=52830395&ns_map=39290872_6081712982008&ts=133411801
3 HTTP ...

I cannot match the whole expression between GET and HTTP because there is a new line (\n). Any idea?

Gabriel Muñumel
  • 1,876
  • 6
  • 34
  • 57
  • It seems you try to get the URL of a HTTP `GET` request. However, there should not be any newline in the request line if you follow the HTTP specification, which leads me to think you have an invalid HTTP request. – Some programmer dude Apr 11 '12 at 06:55
  • Well, i'm getting a lot of HTTP request from a tool called [ngrep](http://ngrep.sourceforge.net/). I read that the output could be modify to be wider. I'll check out later. – Gabriel Muñumel Apr 11 '12 at 14:09

1 Answers1

0

You should take a look at the documentation: http://linux.die.net/man/3/pcrecpp

Most notably look at the section titled "Passing Modifiers To The Regular Expression Engine".

You are probably interested in using the PCRE_MULTILINE and PCRE_DOTALL options. With the DOTALL option you wouldn't have to do the OR you are doing. "." would match newline characters as well.

drewag
  • 93,393
  • 28
  • 139
  • 128