简体   繁体   中英

How to find rows with only special characters on a field using MySQL?

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?

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 string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM