6

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.

0

2 Answers 2

6

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

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

Comments

0

Mysql does not provide regex based extraction from strings, but you can extend mysql to do this:

https://github.com/mysqludf/lib_mysqludf_preg

It's not a good solution for a lot of people though. eg you couldn't use it in a shared hosting environment.

Comments

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.