search
LoginSignup
58

More than 5 years have passed since last update.

posted at

updated at

正規表現クラス[:alnum:]の罠

[:alnum:] って a-zA-Z0-9 と等価だと思っていたが違う。

てっきり

"ほげ".match(/[[:alnum:]]+/)   # => nil

となるのを期待していたのに、

"ほげ".match(/[[:alnum:]]+/)   # => #<MatchData "ほげ">

となる…なんだこれ?

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
58