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?

4

1 回答 1

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.

于 2012-04-11T04:56:27.970 回答