I have a data like under mentioned in table in one column name remarks
Will0017,Will0018, Kind0045 , DGRG0012
I want to extract only numbers from the same only like 0017,0018,0045,0012
How can I do the same in mysql.
I have tried like this
select reject_remarks,regexp_substr(reject_remarks,"[0-9]+") from table;
but have anything like I want
I have tried like this
select reject_remarks,regexp_substr(reject_remarks,"[0-9]+") from table ;
>Solution :
you can use REGEXP_REPLACE where ou negate all possible allowed characters
CREATE Table mytable(reject_remarks varchar(100))
INSERT INTO mytable VALUES ('Will0017,Will0018, Kind0045 , DGRG0012')
SELECT REGEXP_REPLACE(reject_remarks, '[^0-9,[:space:]]+', '') AS numbers
FROM mytable;
| numbers |
|---|
| 0017,0018, 0045 , 0012 |