Method: Sequence::StringLike#match
- Defined in:
- lib/sequence/stringlike.rb
#match(rex, anchored = true, len = maxmatchlen(false)) ⇒ Object
like match_fast, but anchors work correctly and post_match is set to something, if not exactly what you expected. (an Sequence, not String.) 2nd parameter determines if match is anchored on the left side to the current position or not.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/sequence/stringlike.rb', line 130 def match(rex,anchored=true, len=maxmatchlen(false)) newrex=nearend(len)? rex : group_anchors(rex,false,false).first #do the match against what input we have matchdata=match_fast(newrex,false,len) if !matchdata or anchored && matchdata.begin(0).nonzero? self.last_match=Thread.current[:last_match]=nil return end posi=position;posi.move matchdata.end(0) result=fixup_match_result(matchdata,[],pos,:post) { posi.subseq(posi.pos..-1) } #note: post_match is a SubSeq #rex.last_match= self.last_match=Thread.current[:last_match]=result end |