On Wed, May 22 2024, Philip Kaludercic wrote: > Joost Kremers writes: >> +(defun csv--unquote-value (value) >> + "Remove quotes around VALUE. >> +If VALUE contains escaped quote characters, un-escape them. If >> +VALUE is not quoted, return it unchanged." >> + (save-match-data >> + (let ((quote-regexp (apply #'concat `("[" ,@csv-field-quotes "]")))) >> + (string-match (concat "^\\(" quote-regexp "\\)\\(.*\\)\\(" quote-regexp "\\)$") value) > > Shouldn't this `string-match' be in the if-let? I considered that, but in this particular case, `(match-string 1 value)` returns nil if the first character of `value` isn't in `csv-field-quotes`, so it seems to be OK. Emphasis on "seems" though... Plus, there's no need to call `match-string` at all if `string-match` failed, of course. So new patch attached. > Take this example, > > (let ((str "1 2 3")) > (list (string-match "2" str) > (match-string 0 str) > (string-match "4" str) > (match-string 0 str))) > ;;=> (2 "2" nil "2") > > even though string-match failed, the match data remains and matc-string > returns non-nil values. Oh... I kinda assumed that `string-match` would always reset all of the match data, but apparently not. Good to know! Thanks, Joost -- Joost Kremers Life has its moments