Subject: Re: bug#33175: 26.1; match-string

From: Noam Postavsky <[email-masked]>
Date: Sat, 27 Oct 2018 07:10:16 -0400

tags 33175 notabug
close 33175
quit

濱田和明 <[email-masked]> writes:

> (progn
>    (string-match "\\(key[ \t]*\\)= \\(.*\\)" (buffer-string))
>    (match-string 0))
>
> Key = 100
> ->#("
> Key = 10" 0 1 (fontified t) 1 9 (fontified t))
>
> Is not “key = 100”?

    (match-string NUM &optional STRING)

    [...]
    STRING should be given if the last search was by ‘string-match’ on STRING.

Try this instead:

    (let ((str (buffer-string)))
       (string-match "\\(key[ \t]*\\)= \\(.*\\)" str)
       (match-string 0 str))