Regular expression in MYSQL

Regular expression in MYSQL

Regular expression is one of the most powerful tool for the developer
who are dealing with the string in any language .Mysql also support
regular expression patten match by which we can make our work more
efficient

the operator of Regular expression in REGEXP

examples
regexp ‘^abc$’ => will match exactly abc
regexp ‘^ab{2}c$’ => will match exactly abbc
regexp ‘^ab{0,2}c$’ => will match ‘ac’ or ‘abc’ or ‘abbc’
regexp ‘^ab{2,}c$’ => will match ‘abbc’,'abbbc’,…….

We can use the regexp instead of ‘OR’.

We can replace the query

” select *
from user
where name like ‘%alpha%’
or name like ‘%beta%’

With

select *
from user
here name regexp ‘(alpha|beta)’

both will do the same function.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.