jeudi 13 août 2015

'?' not working in C Posix regular expressions

I am trying to extract a string within double quotes in C. For example:

String[100] = "Hi,\"This is awesome\" and \"So is this\""

I only need to find the first match, "This is awesome". And this is what I tried,

regcomp(&preg, "\"(.*?)\"", REG_EXTENDED);
regexec(&preg, String, 2, regm, 0);

where regm is the match array.

Instead of "This is awesome", I get "This is awesome and So is this" as the match.

Shouldn't the ? in (.*?) limit the reg exp to finding the first match?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire