MySQL Find location of first non-numeric character in string

551 views Asked by At

I would like to find the location of the first non-numeric (0-9) character in a string. That is, a space, a dash, a letter or anything but a number.

I seem unable to combine locate with regex to get a result like this:

Data      Output
----------------
12a       3
5E914     2
345-347   4
4 c       2
1

There are 1 answers

2
Akina On
SELECT REGEXP_INSTR(`Input`, '[^0-9]') AS `Output`
FROM `table`