# Regexp \[:punct:\] character class

**URL:** <https://www.ruby-forum.com/t/regexp-character-class/176818>\
**Category:** Ruby\
**Created:** [October 6, 2009, 5:29pm UTC](https://www.ruby-forum.com/t/regexp-character-class/176818 "2009-10-06T17:29:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [October 6, 2009, 5:29pm UTC](https://www.ruby-forum.com/t/regexp-character-class/176818/1 "2009-10-06T17:29:49Z")

</div>

So every piece of documentation on ruby regexps I can find, including  
the pickaxe book, lists that the [:punct:] POSIX character class is  
valid.

But it doesn’t actually work. It just gets treated as a standard  
character class including the chars :,p,u,n,c,t.

Is there something I’m missing? Is there some way to actually use  
[:punct:] in a ruby regexp to mean the POSIX character class as  
documented?

Thanks for any help!

Jonathan

---

<div class="post-metadata">

**Author:** ![jrochkind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jrochkind](https://www.ruby-forum.com/u/jrochkind)\
**Post date:** [October 6, 2009, 5:41pm UTC](https://www.ruby-forum.com/t/regexp-character-class/176818/2 "2009-10-06T17:41:31Z")

</div>

As always, I figured it out right after I posted it. The POSIX character  
class tokens need to go inside character class brackets, resulting in  
double brackets:

/[[:punct:]]/
