mattn / mruby-onig-regexp

mrbgem of 鬼雲's Regular Expression
31 stars 36 forks source link

Freeze regex variable #83

Closed proyb6 closed 6 years ago

proyb6 commented 6 years ago

Is there a way to free regex in variable that should not be change through out lifetime? It appear I couldn't get the match working.

Working:

/^[A]{1}[0-9]{6}[A-Z]{1}$/.match?("A123456A".freeze) ? "" : res << {"IC" => "err1"}

Wanted:

ic = Regex.new("/^[A]{1}[0-9]{6}[A-Z]{1}$").freeze
take-cheeze commented 6 years ago

What do you want?:

Regexp object is immutable currently so OnigRegexp#freeze should work.