Sha256: 0dae06396f3ab440614634b49f6a5115e4e495fca4d00295d8ba39297829167b

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

module Wiris
	class EReg
		def regex=(regex)
			@regex=regex
		end
		def regex
			@regex
		end

		def match=(match)
			@match=match
		end
		def match
			@match
		end

		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

		def match(str)
			@match = @regex.match(str)
			if (@match.nil?)
				return false
			else
				return true
			end
		end

		def replace(str, by)
			@match = @regex.match(str)
			if @match.nil?
				return str
			else
				return str.gsub(@match.regexp, by)
			end
		end

		def matched(n)
			return @match[n]
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wirispluginengine-3.62.0.1322 lib/src-generic/EReg.rb