MySQL Forums
Forum List  »  Full-Text Search

Re: how to find particular string from text column
Posted by: Rick James
Date: June 01, 2010 09:02PM

"Mastering Regular Expressions" is a good book.

Here's a breakdown of '(^|[|])SEWER\s*:\s*Septic([|]|$)'
(|) -- either of the two things inside ('|' means 'OR').
^ -- start of string ("anchored" at beginning) -- I am assuming your text could be
If, instead you are sure to have '|' at both ends, as
then the regexp could be simplified to:

$ -- anchor at end
[] -- any of the set of characters inside. In this case [|], I am avoiding the special meaning of '|' as 'OR'
SEWER and : and Septic -- exact matches on those strings
\s -- "white space", that is, space, tab, carriage return, etc.
* -- zero or more of what preceeds (contrast + meaning 1 or more, and ? meaning 0 or 1)
\s* -- zero or more spaces, tabs, etc. (probably zero in your case)

Possibly, this is all you need:
REGEXP '[|]SEWER:Septic[|]'
LIKE '%|SEWER:Septic|%'
The percents are there because LIKE is anchored by default, unlike REGEXP.
LIKE tends to be faster (in MySQL), but REGEXP is more powerful.
LIKE has only two special characters ( % _ ); REGEXP has lots.

Options: ReplyQuote

Written By
Re: how to find particular string from text column
June 01, 2010 09:02PM

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.