tags:

views:

18

answers:

1

Hi Everyone, I'm trying to check if a name has invalid characters, so far I've managed to get everything I need apart from checking for capitalization, I've tried using

SELECT BINARY('jiLl') REGEXP('[[:upper:]]+');

but unfortunately that also flags properly formatted names, as in (Jack), is it possible to have the regex ignore the first character of the name, and if so how?

Thank you in advance, --a

A: 

Take one step back and rethink ;)

Give me all instances that don't start with a capital letter and the rest are lower-case:

mysql> SELECT BINARY('JacK') NOT REGEXP('^[[:upper:]][[:lower:]]+$') AS is_invalid;
+------------+
| is_invalid |
+------------+
|          1 |
+------------+
1 row in set (0.00 sec)

mysql> SELECT BINARY('jiLl') NOT REGEXP('^[[:upper:]][[:lower:]]+$') AS is_invalid;
+------------+
| is_invalid |
+------------+
|          1 |
+------------+
1 row in set (0.00 sec)

mysql> SELECT BINARY('Jack') NOT REGEXP('^[[:upper:]][[:lower:]]+$') AS is_invalid;
+------------+
| is_invalid |
+------------+
|          0 |
+------------+
1 row in set (0.00 sec)
nicomen
Oh that is great! I completely dismissed the opportunity to do it the reverse way. Great stuff nicomen.Thank you very much!--a
schizix
apologies, I can't seem to rate the answer just yet as I need 15 reputation to do it, but it's most def a +1, appreciate the tip, once again many thanks
schizix
My pleasure, I had to step back myself ;)
nicomen