Find the position of a regex substring in mysql

2019-09-02 17:57发布

问题:

I need to extract a few fields of data from many lines of text. The data I am looking for is always in the same format ("from #.#####.##########") but it always contains different data. I know I can use regex to determine if that pattern is met... but I know the pattern is met. I want to know where in the string the pattern is met so that I can substring it out of there. Is that possible?

So a few of the lines of text might look like...
Oh, hello there. Blah blah blah. from 1.12345.1234567890 doopeedoo whoop!
Lay tee dah good sir! from 3.98766.123487650 and some other stuff!

Thanks in advance!

回答1:

Try this:

/from \d+\.\d+\.\d+/

Your example on Rubular.



回答2:

As Orbling noted, there doesn't seem to be a function for returning the string, only telling if it exists or not. I ended up using wild substring and index search functions.