Wednesday, 15 May 2013

regex - How to use SUBSTRING using REGEXP in MySQL -



regex - How to use SUBSTRING using REGEXP in MySQL -

i have situation, have substring regular look description using mysql.

descritpion:

lorem ipsum dolor sit down amet, consectetur adipiscing elit. sed ac magna enim, european union adipiscing sapien. cras lacinia vulputate elit, sed adipiscing felis interdum a. cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. phasellus sit down amet ante orci. d9801 quisque dignissim posuere quam, id suscipit nisl scelerisque nec.

where d9801 regexp. every description has different content reg exp should looks like: regexp 'd[[:digit:]]{4}'

i know regexp homecoming true/false value, how can create query homecoming d9801 value?

i tried this:

select substring (description, locate(regexp 'd[[:digit:]]{4}', description), 5) ( select "lorem ipsum dolor sit down amet, consectetur adipiscing elit. sed ac magna enim, european union adipiscing sapien. cras lacinia vulputate elit, sed adipiscing felis interdum a. cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. phasellus sit down amet ante orci. **d9801** quisque dignissim posuere quam, id suscipit nisl scelerisque nec." description ) temp

but know totally wrong... help appreciate.

mysql doesn't provide function. can check out udf.

take close @ function : regexp_substr(text, pattern [,position [,occurence [,mode]]])

mysql regex substring

No comments:

Post a Comment