MySQL Forums
Forum List  »  General

Re: REGEXP - search for "something\QQQsomething"
Posted by: Felix Geerinckx
Date: October 10, 2005 11:41AM

Consider the following (slightly changed) example:

USE test;
DROP TABLE IF EXISTS foo;
CREATE TABLE foo (
d CHAR(20) NOT NULL
);

INSERT INTO foo VALUES ('\\QQQsomething');
SELECT * FROM foo;
SELECT * FROM foo WHERE d REGEXP '^\QQQ';
SELECT * FROM foo WHERE d REGEXP '^\\QQQ';
SELECT * FROM foo WHERE d REGEXP '^\\\QQQ';
SELECT * FROM foo WHERE d REGEXP '^\\\\QQQ';

only the first and the last SELECT produce a result, because the regexp string is parsed twice: once by normal string parsing (turning '\\\\' into '\\') and once by the regexp engine (turning '\\' into '\').

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
Re: REGEXP - search for "something\QQQsomething"
October 10, 2005 11:41AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.