Problem Regular expression


Good I need to take a number of some text string and I can not get the regular expression that I need here the example.


Hello, such # 4702665


Welcome 45454545 tal # 470815 BD. WA470815

I need only these numbers: # 470815 # 4702665 in those two sentences but without the pad the rest I discard everything.

SELECT comment, type, comment as numero FROM Transicion WHERE comment REGEXP '#[0-9]+'

Let's see if anyone can help me thanks.

I have managed to get it but it does not work for my DB since it uses mysql5.7 someone knows some solution to be able to apply it to my DB

 SELECT id, comment, SUBSTRING(comment, '#([0-9]+)') AS user_id
 FROM transiction;

Any ideas to apply that to mysql 5.7 ??

doing it with sql REGEXP '# [0-9] +' what it does is tell me the number of times that pattern matches, what I need is for me to show that value. Any help please?

asked by alfonso Perez 05.12.2018 в 17:38

1 answer


You can try something like:

"#[0-9]+" //matchea el número con el símbolo "#"

"(?<=#)[0-9]+" //matchea sólo el número (cuidado, puede no ser soportada en todos los navegadores)

You can try the expression in this site

answered by 05.12.2018 в 17:53