Isolate an email address from a string using MySQL -
i trying isolate email address block of free field text (column name text).
there many different variations of preceding , succeeding characters in free text field, i.e.:
email me! john@smith.com e:john@smith.com m:555-555-5555 john@smith.com--personal email
i've tried variations of instr()
, substring_index()
first isolate "@"
(probably 1 reliable constant in finding email...) , extracting characters left (up until space or non-qualifying character "-"
or ":"
) , doing same thing text following @
.
however - i've tried far hasn't filtered out noise level need.
obviously 100% accuracy isn't possible mind taking crack @ how can structure select statement?
there no easy solution within mysql. can after have retrieved using regular expressions.
here example of how use in case: regex example
if want select e-mail addresses 1 string: regex example
you can use regex extract ones contain e-mail in mysql still doesn't extract group string. has done outside mysql
select * table column rlike '\w*@\w*.\w*'
rlike
matching it, can use regexp
in select
returns 1 or 0 on whether has found match or not :s
if want extract in mysql maybe other stackoverflow post helps out. seems lot of work instead of doing outside mysql
Comments
Post a Comment