Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Got error 'invalid repetition count(s)' from regexp

Tags:

regex

mysql

I got the following error in mysql:

Got error 'invalid repetition count(s)' from regexp

My query is:

SELECT * FROM table WHERE some_text_field REGEXP"[A-Za-z0-9]{256}"

But when I replace REGEXP"[A-Za-z0-9]{256}" with REGEXP"[A-Za-z0-9]{255}" and below there is no error.

Is there any character limitation in REGEXP? Why does it not work when I use 256 or above but works when I replace it with 255 or below?

I looked into this, Mysql throwing exception on Regex, but it is not very informative on why the error is occurring.

like image 680
Avinash Avatar asked Jan 22 '13 12:01

Avinash


1 Answers

As documented under Regular Expressions:

To be more precise, a{n} matches exactly n instances of a. a{n,} matches n or more instances of a. a{m,n} matches m through n instances of a, inclusive.

m and n must be in the range from 0 to RE_DUP_MAX (default 255), inclusive. If both m and n are given, m must be less than or equal to n.

like image 137
eggyal Avatar answered Oct 19 '22 19:10

eggyal