escaping strings properly for use with REGEXP

escaping strings properly for use with REGEXP

am 02.05.2003 15:27:28 von Mark Stosberg

Hello,

I'm writing a web application using DBD::mysql. I would like for the
user to enter some keyword search terms that become part of a REGEXP
clause, like:

field REGEXP 'term1|term2|term3',

However, I don't want anything the user enters to have special meaning
in my regular expression. For example, you can see with this test query,
MySQL throws an error:

# mysql> select 'big blue truck!' regexp 'Big|Blu~e|[[.charactersfu)ck{';
# ERROR 1139: Got error 'brackets ([ ]) not balanced' from regexp

I think with Perl regular expressions this is easy using "\Q" and "\E".
There doesn't currently seem to be an easy way to do this with MySQL.
Any help is appreciated.

Thanks,

Mark

--
http://mark.stosberg.com/


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules=x 7+yCfqV/g9AfugRpC6u6w@public.gmane.org