Abeer zaroor
Abeer zaroor

Reputation: 320

white space Regex in mysql

according to mysql regex we can use [[:space:]]* instead of \s* so I have this query

select * from onet.tools_and_technology where t2_example  Rlike '[[:space:]]*C++[[:space:]]*';

but it gives me this error

Error Code: 1139. Got error 'repetition-operator operand invalid' from regexp

what I'm missing here??!!

Upvotes: 2

Views: 1657

Answers (1)

Laurel
Laurel

Reputation: 6173

The + character is similar to the * character in a regex: they're meta characters.

You need to escape each character with \. Because you are working in a string, you will need to escape the escape: '[[:space:]]*C\\+\\+[[:space:]]*'


Your problem can be solved without regexes, though: LIKE '% c++ %'

This is much more readable.

Upvotes: 3

Related Questions