1

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!

1
  • Welcome to SO... What did you try ? and what result did you get ? Commented Jan 7, 2014 at 14:42

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.