Sha256: f603a6dbb02371e92eb662dae56de69732663ef96fb637151192c4fb350eb42d
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
class Regexp < `RegExp` def self.escape(string) `string.replace(/([.*+?^=!:${}()|[\]\\/\\])/g, '\\$1')` end def self.new(string, options = undefined) `new RegExp(string, options)` end def ==(other) `other.constructor == RegExp && this.toString() === other.toString()` end def ===(obj) `this.test(obj)` end def =~(string) %x{ var result = this.exec(string); if (result) { result.$to_s = match_to_s; result.$inspect = match_inspect; result._real = result._klass = #{ MatchData }; #{$~ = `result`}; } else { #{$~ = nil}; } return result ? result.index : nil; } end alias eql? == def inspect `this.toString()` end def match(pattern) %x{ var result = this.exec(pattern); if (result) { result.$to_s = match_to_s; result.$inspect = match_inspect; result._real = result._klass = #{ MatchData }; return #{$~ = `result`}; } else { return #{$~ = nil}; } } end def to_s `this.source` end %x{ function match_inspect() { return "<#MatchData " + this[0].$inspect() + ">"; } function match_to_s() { return this[0]; } } end class MatchData end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opal-0.3.20 | core/regexp.rb |