We all know the regular expression character classes, right? There are 12 standard classes:

[:alnum:]  [:digit:]  [:punct:]
[:alpha:]  [:graph:]  [:space:]
[:blank:]  [:lower:]  [:upper:]
[:cntrl:]  [:print:]  [:xdigit:]

But have you seen a visual representation of what these classes match? Probably not. Therefore I created a visualization that illustrates which part of the ASCII set each character class matches. Call it a cheat sheet if you like:


small version, large version

A bunch of programs that I used

Just for my own reference, in case I ever need them again, here are the one-liners I used to create this cheat sheet:

perl -nle 'printf "%08b - %08b\n", map { hex "0x".(split / /)[0], hex "0x".(split / /)[1] } $_ '
perl -nle 'printf "%03o - %03o\n", map { (split / /)[0], (split / /)[1] } $_'

And I used this perl program to generate and check the red/green matches:

use warnings;
use strict;

my $red = "\e[31m";
my $green = "\e[32m";
my $clear = "\e[0m";

my ($start, $end) = @ARGV;

die 'start or end not given' unless defined $start && defined $end;

my @classes = qw/alnum alpha blank cntrl digit graph lower print punct space upper xdigit/;

for (map { chr } $start..$end) {
    for my $class (@classes) {
        print "${green}1${clear}" if /[[:$class:]]/;
        print "${red}0${clear}" unless /[[:$class:]]/;
    }
    print "\n"
}

Credits

I was inspired to create this visualization when I saw a similar table for C's ctype.h character classification functions.

Comments

Altreus Permalink
February 26, 2013, 08:43

Save on a call to split with

map { (split / /)[0,1] }

:)

September 30, 2013, 05:21

hi, Man that is super helpful to have! Great idea, I have a bunch of char cheat-sheets I use all the time, but this is a new one. Thanks for sharing!!

July 27, 2014, 20:17

Man that is super helpful to have! Great idea, I have a bunch of char cheatsheets I use all the time, but this is a new one. Thanks for sharing!!

just download subway surfers for pc Man that is super helpful to have! Great idea, I have a bunch of char cheatsheets I use all the time, but this is a new one. Thanks for sharing!!

November 13, 2014, 09:26

yes thanks but Free mobile recharge tricks is good idea too ;) newbie blogger

November 13, 2014, 09:26

yes thanks but Free mobile recharge tricks is good idea too ;) newbie blogger

November 15, 2014, 14:41

idm cc whatsapp status Nice one bro ...

November 16, 2014, 04:16

How to use Kik Messenger on PC
How to Use Kik Messenger on Laptop and Windows PC

..............................

December 01, 2014, 20:34

You guys really doing good job by sharing very nice updates.Well i would also like to share How to Run Andorid apps on PC using Bluestacks Offline Installer including step by step tutorial.digg 100% free

February 26, 2013, 15:57

Man that is super helpful to have! Great idea, I have a bunch of char cheatsheets I use all the time, but this is a new one. Thanks for sharing!!

August 20, 2014, 13:00

Nice information, Keep it up. Keep blogging. i want to looking to reading your next post eagerly.
share your files.

Justin Permalink
February 28, 2013, 17:54

I rarely see these character classes used because they tend to obscure the meaning of regular expressions because support across the standard unix tools and documentation is uneven. For example, GNU grep supports [:blank:] but the man page for GNU grep doesn't mention it. Solaris grep doesn't support character classes at all, unless you're using /usr/xpg4/bin/grep, which may. YMMV with HP-UX, AIX, IRIX/ULTRIX, etc, which all ship with their own custom implementations of regular expressions. GNU Emacs adds [:unibyte:], [:multibyte:], [:word:], [:nonascii:], [:graph:], [:ascii:], and some of those are also defined in the POSIX standard. Python may not support "standard" character classes at all-- I couldn't find any mention of them in the online docs. The actual meaning of these character classes varies as well depending on your locale environment variables. This sometimes is a good thing! Ultimately, unless you have the privilege of controlling where your regular expression is used in all cases, you have to fall back to the minimum supported syntax.

Charles Crawford Permalink
July 09, 2013, 00:29

This is very helpful! Definitely happy with this post. Thank you for sharing this.

July 12, 2013, 04:34

very useful article . thanks a lot..

July 18, 2013, 05:16

holla man (y)

July 18, 2013, 05:18

Oh my goodness! an remarkable post dude. Thank you On the other hand I’m experiencing problem with ur rss . Do not know why Unable to subscribe to it. Is there any person finding identical rss challenge? Any individual who knows kindly respond. Thnkx

July 24, 2013, 02:36

great info. thanks

Eric Permalink
August 15, 2013, 14:12

Nice, Do you know if there is a Ruby script available? I'd like to compare what is different. Thanks
Eric

November 01, 2013, 17:50

The actual meaning of these character classes varies as well depending on your locale environment variables. This sometimes is a good thing! thanks for sharing.

November 01, 2013, 17:51

This is technology article learning site where are available Latest technology news,tech news,,science and technology, Education Technology, SEO tips, Mobile technology.

Dillon Permalink
December 25, 2013, 21:10

Being a student you should always remember to collect diverse sources where you can buy dissertations especially this here believed to do by all greatest mind of past centuries. Learn and teach at the same time while discussing any-what problem or completing any given task. Underline all strong features and strengthen insufficiency or lack of exactitude when doing a research for you or me on a daily basis.

March 03, 2014, 17:03

Wow what a good post thanks for such a help

April 08, 2014, 07:24

Maybe that will be success

April 19, 2014, 06:03

thanks for the info IBPS Reasoning .

April 26, 2014, 03:46

Wow what a good post thanks for such a help.download WhatsApp for PC this information is really informative.

May 14, 2014, 04:25

This is very useful and helpful Definitely. Thank you for sharing this post. i am from manabadi ap 10th class results 2014.

July 12, 2014, 06:18

Thats really helpful, you saved my exmas.
Box Office Collection

July 13, 2014, 07:48

Awesome tutorial to get backlinks. I will sure try and ask you if need further help to get good backlinks if you don't mind.

Mouri Permalink
July 20, 2014, 18:03

Hello, and thank you Whatsapp for PC download for computer

August 04, 2014, 12:24

HelpFul Post
Visit : www.anytimeseo.blogspot.com For Seo tips and Tricks

September 12, 2014, 10:33

Thanks for taking the time to discuss this, I feel strongly that love and read more on this topic. If possible, such as gain knowledge, would you mind updating your blog with additional information? It is very useful for me.

Moun Permalink
September 16, 2014, 06:45

You can download SubWay Surfers for PC to help you in this field and course.

Magnan Permalink
September 16, 2014, 06:56

Free download iMessage for Windows is what you need now. Please keep us informed about that

Rishi Permalink
October 11, 2014, 05:06

Wow what a nice site it is. Meanwhile check this out too Shruti Hassan Hot .

Rakhi Permalink
October 11, 2014, 05:10

It is very vey nice site really its a fab Shruti Hassan Hot Must Watch

October 25, 2014, 06:42

WHATSAPP FOR PC jkfhkdsjfh

indresults2015.com Permalink
November 29, 2014, 16:31

Nice information, Keep it up. Keep blogging. i want to looking to reading your next post eagerly.

Visit Latest 2015 Job Updates on My Blog

November 30, 2014, 09:13

http://technolact.blogspot.in/2014/11/get-candy-crush-free-lives-instantly-android-ios.html

jaydeep patel Permalink
December 01, 2014, 08:45
December 02, 2014, 07:26

thanks for sharing with us!!!!! and i really appreciate to continue this......

December 02, 2014, 07:28

Thanks For sharing This with Us.... And i appreciate you to continue this work ahead

Kaur deep Permalink
December 04, 2014, 03:32

Excellent and knowledgeable links and post.thanks for sharing.
Now, The Time has come for the Happy New Year 2015. It wil bring a lot fo happinesin our life.
Happy New Year 2015
And I am sure, You wil anjoy this new year day with yoru fiends and wil send some images wishes,
New Year 2015

Happy New Year 2015 Wishes
Greetings to yoru close ones, Your friends, You lover, etc..
Happy New Year 2015 Images
Even I am waititng for that day, because it just changes our life.
Happy New Year 2015 Greetings

Happy New Year 2015 SMS
So, That's why I am commenting here to wish you a very happy new year.
Happy New Year 2015 Messages
I hope this New year 2015 wil bring success to your website. But before that Merry Christmas is coming.
Merry Christmas Quotes
It is also a big event for everyone.
Merry Christmas Pictures
Everyone knows that Christmas is a day when People seems to be very happy, they just leave all sadness behind.
Merry Christmas Wallpapers
And I am sure, you also enjoy this Merry Christmas day of 2014.
Christmas day Images

Christmas stocking
But if you are not looking out to enjoy this christmas, then you are missing out on a big thing, because it really brings happiness.
Merry Christmas Images

Merry Christmas 2014
So, what you are waiting for?
Merry Christmas 2015
Enjoy This Merry Christmas day. Cheers :).

December 04, 2014, 20:24

Hey Admin.. Thanks alot I liked Ur Post

Hi... My Friends

Check It Trick - Its Helpfull to u hOW TO GET 1220 BACKLINKS IN 5 HOURS.

December 09, 2014, 09:40

nice
a href=" http://mynycstreets.com/2014/12/download-lingaa-movie-torrentlingaa-movie-free-download/">Lingaa Movie Torrent Downl

<oad>

lingaa movie in mp4lingaa movie in hdlingaa movie in free downloadLingaa Movie download in torrentfree download lingaa movie
diggnice article

December 10, 2014, 14:04

recruitment-career. in Provides Latest & important Updates about Work opportunities in Private & government industry.

adsdesh Permalink
December 10, 2014, 14:24

Hi, Thanks for an excellent share. If you like to drive your car when you want and are interested on American automobile industry you may also like to read american car brands to learn more.

Leave a new comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "disk_378": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.

Advertisements