lib/regextest/regex-option.rb in regextest-0.1.5 vs lib/regextest/regex-option.rb in regextest-0.1.6
- old
+ new
@@ -86,9 +86,36 @@
# modify options by integer
def modify_integer(options)
@reg_options |= options
end
+ # generate prefix regex
+ def prefix_reg
+ prefix = ""
+ prefix += "i" if is_ignore?
+ prefix += "m" if is_multiline?
+ prefix += "x" if is_extended?
+
+ if prefix.size > 0
+ "(?#{prefix})"
+ else
+ ""
+ end
+ end
+
+ # get charset ("a", "u", or "d")
+ def charset
+ case @char_set
+ when TstRegOptDefault
+ "d"
+ when TstRegOptAscii
+ "a"
+ when TstRegOptUnicode
+ "u"
+ else
+ raise "Internal error. Invalid char_set (#{@char_set})"
+ end
+ end
# methods for checking each flag
def is_ignore?
(@reg_options & Regexp::IGNORECASE != 0)
end