Opened 12 years ago

Closed 12 years ago

#889 closed defect (invalid)

irregex-match-end gives odd results with chunked searches

Reported by: megane Owned by:
Priority: major Milestone:
Component: core libraries Version: 4.7.x
Keywords: irregex Cc:
Estimated difficulty:


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 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)

Change History (1)

comment:1 Changed 12 years ago by Alex Shinn

Resolution: invalid
Status: newclosed

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.

Note: See TracTickets for help on using tickets.