class Wiris::EReg

Public Class Methods

new(pattern, opts=nil) click to toggle source
# File lib/src-generic/EReg.rb, line 17
def initialize(pattern, opts=nil)
        flags = 0
        if not opts.nil?
                for i in 0..opts.length
                        case opts[i]
                        when "i"
                                flags += Regexp::IGNORECASE
                        when "s"
                                flags +=  Regexp::MULTILINE
                        when "m"
                                flags +=  Regexp::MULTILINE
                        end
                end
        end
        @regex = Regexp.new(pattern, flags)
end

Public Instance Methods

match() click to toggle source
# File lib/src-generic/EReg.rb, line 13
def match
        @match
end
match=(match) click to toggle source
# File lib/src-generic/EReg.rb, line 10
def match=(match)
        @match=match
end
matched(n) click to toggle source
# File lib/src-generic/EReg.rb, line 52
def matched(n)
        return @match[n]
end
regex() click to toggle source
# File lib/src-generic/EReg.rb, line 6
def regex
        @regex
end
regex=(regex) click to toggle source
# File lib/src-generic/EReg.rb, line 3
def regex=(regex)
        @regex=regex
end
replace(str, by) click to toggle source
# File lib/src-generic/EReg.rb, line 43
def replace(str, by)
        @match = @regex.match(str)
        if @match.nil?
                return str
        else
                return str.gsub(@match.regexp, by)
        end
end