What is the best way to match only letters in a regex?

SapphireSun picture SapphireSun · Sep 20, 2010 · Viewed 32.2k times · Source

I would really like to use \w but it also matches underscores so I'm going with [A-Za-z] which feels unnecessarily verbose and America centric. Is there a better way to do this? Something like [\w^_] (I doubt I got that syntax right)?

Answer

zigdon picture zigdon · Sep 20, 2010

Perhaps you mean /[[:alpha:]]/? See perlre for the discussion of POSIX character classes.