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.
