Skip to content

Instantly share code, notes, and snippets.

@miyohide
Created September 25, 2012 12:36
Show Gist options
  • Save miyohide/3781517 to your computer and use it in GitHub Desktop.
Save miyohide/3781517 to your computer and use it in GitHub Desktop.
正規表現のサンプル
# pass_check.rb
# coding: utf-8
def pass_check(password)
password =~ /[[:alnum:]!\"#\$%&\'\(\)]/
end
# test_pass_check.rb
# coding: utf-8
require 'test/unit'
require './pass_check'
class TestPassCheck < Test::Unit::TestCase
def test_pass_check
%w(a b c 0 1 2 ! " # $ % & ' \( \)).each do |i|
assert_equal(0, pass_check(i))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment