emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification


From: Johan Bockgård
Subject: Re: Trimming strings, /emacs/lisp/emacs-lisp/subr-x.el modification
Date: Sat, 06 May 2017 19:51:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Jean-Christophe Helary <address@hidden> writes:

> -(defsubst string-trim-left (string)
> -  "Remove leading whitespace from STRING."
> -  (if (string-match "\\`[ \t\n\r]+" string)
> +(defsubst string-trim-left (string &optional regexp)
> +  "Trim STRING of leading string matching REGEXP.
> +
> +REGEXP defaults to \"[ \\t\\n\\r]+\"."
> +  
> +  (if (string-match (concat "\\`" (or  regexp "[ \t\n\r]+")) string)

I think regexp should be surrounded by a grouping construct, like:

   (concat "\\`\\(?:" (or  regexp "[ \t\n\r]+") "\\)")

And similarly for string-trim-right.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]