regex - Redefining the Word Character Class in Perl -


i need change behavior of \w character class in perl. match [a-za-z0-9_.]. is, want add . character class. possible?

i need modify \w because want number of modules (e.g. getopt::long) see things "foo.bar" valid word.

this a) untested b) extremely nasty c) inconvenient should rather comment, alas can't write yet.

i see 2 possibilities:

  • write custom locale \w class uses lc_ctype under use locale determine characters considered "word characters". perllocale manpage mentions security aspect

    regular expression checks safe file names or mail addresses using "\w" may spoofed "lc_ctype" locale claims characters such ">" , "|" alphanumeric.

unfortunately there doesn't seem way (at least on unixish oses, no idea windows) without installing system-global configuration. askubuntu has thread that.

  • monkey-patch required functions. opens different can of worms if don't know respective versions of modules patch users might have (you script though).

all in all, better think twice doing stuff that, it's break other parts of system , in case makes maintenance nightmare.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -