Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extract value using regular expression in mysql

Tags:

mysql

I am storing values in database like this

www/content/lessons/40/Digital Library/document1.doc

I need to extract the file document.doc.

How to retrieve this value from mysql using regular expression.

like image 293
boss Avatar asked Jan 18 '10 09:01

boss


1 Answers

you not need to use regexp (low performence) use substring_index instead

SELECT SUBSTRING_INDEX('bbb/bbbbbb/bbbbbbbbb/bbbb', '/', -1);

link :

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_substring-index

like image 133
Haim Evgi Avatar answered Sep 22 '22 17:09

Haim Evgi