Summary

irregex-match-end gives odd results with chunked searches

Metadata

Description

I expected (irregex-match-end-index m 0) to return 4 in the following example:

 (let* ((chkr (make-irregex-chunker
 	      (lambda (c)
 		(and (pair? c)
 		     (cdr c))) car))
        (m (irregex-search/chunked "(b)" chkr '("foo" "bar"))))
   (print m)
   (print (irregex-match-start-index m 0))
   (print (irregex-match-end-index m 0))
   (print (irregex-match-start-index m 1))
   (print (irregex-match-end-index m 1)))
 
 ;; #<regexp-match (1 submatch)>
 ;; 3
 ;; 1
 ;; 3
 ;; 1

The result with the version from http://code.google.com/p/irregex/ was:

 #(*irregex-match-tag* #(#<procedure (? c)> #<procedure (car p)> #<procedure (? cnk)> #<procedure (? cnk)> #<procedure (? cnk1 start cnk2 end)> #f) () (foo bar) 3 (bar) 1 (foo bar) 3 (bar) 1 #f #f #f #f)
 3
 1
 3
 1

Changes and comments

[2012-07-31 01:50:39 UTC] ashinn changed status from new to closed

[2012-07-31 01:50:39 UTC] ashinn set resolution to invalid

[2012-07-31 01:50:39 UTC] ashinn wrote:

This is correct. In the chunked API, the indexes are not absolute, but instead are relative to the start of the chunk. You can get the chunk with irregex-match-start/end-chunk.

If this is hard to work with you can use irregex-match-substring which will just give you a string regardless of whether the data was chunked or not.