Abeer zaroor Abeer zaroor - 1 year ago 66
SQL Question

white space Regex in mysql

according to mysql regex we can use

instead of

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

what I'm missing here??!!

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download