Reputation: 673
How can we use regular expressions in select queries? For example:-
select regex(column1, regular_expression) from table1
I found REGEXP being used in where clause but cannot find something for selects like above.
For example, phone_number column in database has (845) 545 5545, the select query should return 8455455545
Upvotes: 0
Views: 39
Reputation: 562270
You need MySQL 8.0 for this:
mysql> select regexp_replace('(845) 545 5545', '[() ]', '') as phonenumber;
+-------------+
| phonenumber |
+-------------+
| 8455455545 |
+-------------+
Upvotes: 1
Reputation: 178
Instead of regex you can try replace
SELECT Replace(Replace(Replace(column1,')',''),'(',''),' ','') FROM table1
Upvotes: 0