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)?
相关问题
- $ENV{$variable} in perl
- Improve converting string to readable urls
- Is it possible to pass command-line arguments to @
- Regex to match charset
- Regex subsequence matching
相关文章
- Optimization techniques for backtracking regex imp
- Regex to check for new line
- Allow only 2 decimal points entry to a textbox usi
- Running a perl script on windows without extension
- Comparing speed of non-matching regexp
- Can NOT List directory including space using Perl
- Regular expression to get URL in string swift with
- Extracting columns from text file using Perl one-l
You could use
/[a-z]/i
or/[[:alpha:]]/
just as well. In fact,\w
includes numbers so that won't even work.you're looking for internationalization in your regex? then you'll need to do something like this guy did: JavaScript validation issue with international characters
explicitly match on all of the moon language letters :)
Perhaps you mean
/[[:alpha:]]/
? See perlre for the discussion of POSIX character classes.See perldoc perlre
A few options:
I recommend using either the case-insensitive, or the true way
/[a-zA-z]/
, unless you have a certain language preference in mind.Note:
a-Z
. Also: this method would fail the no-underscore criteria, since it includes [ \ ] ^ _ ` .ʹʺʻˍˎˏːˑˬˮ̀́
(plus many others)Just use
\p{L}
which means "any Unicode letter" and works in Perl (/\p{L}/
). You probably need touse utf8;
.