Last active
April 14, 2019 02:03
-
-
Save shazaum/a4afaf28f607653f34de to your computer and use it in GitHub Desktop.
regex custom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X = Regexp.new("[0-9]") | |
N = Regexp.new("[1-9]") | |
Z = Regexp.new("[2-9]") | |
match_number = "ZNX" # does not works, need convert to "#{Z}+#{N}+#{X}" | |
number = "210" | |
if (number =~ /#{match_number}/) # it works -> /#{Z}+#{N}+#{X}/ | |
puts "match #{number}" | |
else | |
puts "NOK" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment