I need a MySQL query w/ Regex to tell me if my string's first character is a number from 0 to 9.
views:
41answers:
2
+5
A:
The following query returns '1', since the REGEXP matches. You can adapt it for your purposes:
SELECT '123 this starts with a digit' REGEXP '^[[:digit:]]';
You can use it in a SELECT
like this:
SELECT * FROM tbl WHERE field REGEXP '^[[:digit:]]';
zombat
2009-08-21 04:42:48
+2
A:
SELECT 'a12' REGEXP '^[0-9]';
=> 0
SELECT '4ab' REGEXP '^[0-9]';
=> 1
Simon Buchan
2009-08-21 04:44:18