Reputation: 152
Here's the deal, i must find the rows, on which a determined field contains only special characters, I've been trying using regex, with no success.
Can someone help me please?
Upvotes: 2
Views: 3970
Reputation: 627082
You can use
SELECT * FROM table WHERE col REGEXP '^[^[:alnum:][:space:]_]+$'
See the regex demo.
The regex pattern breakdown:
^
- start of string[^
- start of the negated character class that matches any character other than defined in this class
[:alnum:]
- letters and digits[:space:]
- whitespace_
- underscore]
- end of the negated character class+
- the characters matched by the negated character class must be 1 or more occurrences$
- end of stringUpvotes: 7