Answer the question
In order to leave comments, you need to log in
How to compose a regular expression in c++ to recognize a "raw" POST request?
Good day,% habrauser%!
I continue to understand with ++.
The task is to parse a "raw" POST request of the form:
--------------------------a83ff083a93d5629
Content-Disposition: form-data; name="test"
123456
--------------------------a83ff083a93d5629
Content-Disposition: form-data; name="test2"
33333
--------------------------a83ff083a93d5629
Content-Disposition: form-data; name="test3"
777
--------------------------a83ff083a93d5629--
void match_parts_req(string * response)
{
regex expression("\"([a-zA-Z0-9_]+)\"\r\n\r\n(.*[^\r\n])\r\n");
sregex_token_iterator iter(response->begin(), response->end(), expression, 0);
sregex_token_iterator end;
cout<<"\nstart matches\n";
for( ; iter != end; ++iter ) {
cout<<"value of: \n";
cout<<*iter<<'\n';
}
cout<<"end matches\n";
}
Answer the question
In order to leave comments, you need to log in
solved with the help of a rewritten regular expression
regex expression("\"([^\r\n]+)\"\r\n\r\n([^\r\n]+)\r\n");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question