Delinda Dyta Delinda Dyta - 1 year ago 58
MySQL Question

How to select data with REGEXP without containing Extended ASCII

I just want to display data with :

  1. containing a-z

  2. containing A-Z

  3. contain numbers 0-9

  4. contain printable ASCII charachter on the following link

I stuck using code like this, please help point -4 above:

select * from Delin where the address REGEXP '^ [A-Za-z0-9]'

with sample raw data below:

enter image description here

and i wanna output like this(where these images show a-Z and only printable symbols) :

enter image description here

Answer Source

Your items 1–3 (az, AZ, and 09) are all subsets of item 4 (printable ASCII characters), so you need only concern yourself with the latter. The following query satisfies that criterion:

 WHERE alamat REGEXP '^[ -~]+$';

The character class [ -~], indicates the ASCII characters from space to tilde inclusive, which happens to be all of the printable ASCII characters and no others.

You can see it in an SQL Fiddle here:!9/6c7b8/1

Terminology note: There is no such thing as "Extended ASCII." The ASCII character set corresponds to the numbers 0–127 inclusive. Any character corresponding to a number greater than 127 is not ASCII. The term "Extended ASCII" is often mistakenly applied to various non-ASCII encodings, none of which is an "extension" of ASCII in any official sense.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download