Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Non-Capturing Groups in MySQL REGEXP

Tags:

regex

mysql

For some reason I can't seem to use non-capturing groups in MySQL. Is there a way to use them in a MySQL REGEXP?

For non-capturing groups in PHP's PCRE implementation, I use this syntax:

(?:[PATTERN])
like image 378
titiyoyo Avatar asked Aug 19 '11 09:08

titiyoyo


1 Answers

Groups in MySQL regular expressions are not capturing groups, since capturing groups in SQL wouldn't make much sense... well, not without the addition of syntax to support using the captured substrings. So it doesn't support the (?: ) syntax, since this syntax is pointless within MySQL -- the groups already don't capture.

So, ([PATTERN]) IS a non-capturing group.

like image 79
cdhowie Avatar answered Sep 28 '22 11:09

cdhowie