[SOLVED] QRegExp exept capture group
-
wrote on 18 Nov 2011, 08:38 last edited by
Hi All, i have regexp like this:
@%(\d+)(\s*:\s*(\w))(\s,\s*(\d+))*@
and i don't need 2nd and 4th captured field, can i except that fields from regexp? (maybe need write some magic symbol before opened bracket) -
wrote on 18 Nov 2011, 09:05 last edited by
The solution is the help on QRegExp :)
bq.
If we want to use parentheses purely for grouping and not for capturing we can use the non-capturing syntax, e.g. (?:green|blue). Non-capturing parentheses begin '(?:' and end ')'. In this example we match either 'green' or 'blue' but we do not capture the match so we only know whether or not we matched but not which color we actually found. Using non-capturing parentheses is more efficient than using capturing parentheses since the regexp engine has to do less book-keeping.Concretely:
@%(\d+)(?:\s*:\s*(\w))(?:\s,\s*(\d+))*
-
wrote on 18 Nov 2011, 09:05 last edited by
@%(\d+)(?:\s*:\s*(\w))(?:\s,\s*(\d+))*@
-
wrote on 18 Nov 2011, 09:14 last edited by
tnx a lot!
Don't read to that paragraph, i remember so need write some symbol, but what exactly - can't remember. :(
1/4