Sha256: a9ed704c53ebeb76381b39bb32b7d114f85098ebb8fda4c605d96f5e29e99f82

Contents?: true

Size: 666 Bytes

Versions: 9

Compression:

Stored size: 666 Bytes

Contents

module Aio::Base::Toolkit
	module Regexp
		class << self
			def to_reg(cmd)
				res = cmd.gsub(' ', '([^\s]*)\s+')
				res.insert(0, '^')
				res.insert(-1, '([^\s]*)$')
				return ::Regexp.new(res)
			end

			def blank
				return /^[\t]*$/
			end

			# 产生一个安全的正则表达式
			def safe(reg)
				res = reg.to_s.gsub(' ', '\s+')
				return ::Regexp.new(res)
			end

			# 将一个数组的正则表达式合并成为一个正则表达式
			def merge(arr_regs)
				str_arr = []
				arr_regs.each {|x| str_arr << x.to_s}
				new_reg = str_arr.join("|").gsub("?-mix:", "")
				new_reg = ::Regexp.new(new_reg)
				return new_reg
			end
		end
	end
end
		

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
aio_elin-1.0.7 lib/aio/base/toolkit/regexp.rb
aio_elin-1.0.6 lib/aio/base/toolkit/regexp.rb
aio_elin-1.0.5 lib/aio/base/toolkit/regexp.rb
aio_elin-1.0.4 lib/aio/base/toolkit/regexp.rb
aio_elin-1.0.3 lib/aio/base/toolkit/regexp.rb
aio_elin-1.0.2 lib/aio/base/toolkit/regexp.rb
aio_elin-1.0.1 lib/aio/base/toolkit/regexp.rb
aio_elin-1.0.0 lib/aio/base/toolkit/regexp.rb
aio_elin-0.0.1 lib/aio/base/toolkit/regexp.rb