sorry for my English.
Please help with pregex in MySql. I want to find two words in text. Between this words can be one or more spaces and/or punctuation mark.
For example:
Tree, apple
Tree , apple
Tree ,apple
Tree ,apple
Tree,apple
Thanks you!
-
Welcome to SO... What did you try ? and what result did you get ?Enissay– Enissay2014-01-07 14:42:56 +00:00Commented Jan 7, 2014 at 14:42
Add a comment
|
1 Answer
MySQL natively supports RegEx since 5.1. Are you looking for something like:
SELECT * FROM `mytable` WHERE `mycol` REGEXP '[[:alpha:]]+[ ,.]*[[:alpha:]]+'
For more information, check out the MySQL Documentation
1 Comment
atomman
Given the examples in the post I would presume you should use
alpha instead of alnum. It is also worth noting that RLIKE is a synonym for REGEXP and could be used as well, although I prefer REGEXP as the name better highlight the functionality of the operator.