lua-users home
lua-l archive

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

I'd like to propose the following extension for future versions of string.gsub (it is described below in the form of an indented insertion into the Manual text):

If the value returned by the table query or by  the function
call  is  a  string  or  a number,  then it  is used  as the
replacement string
    (if the function returns a second  value and  that value
    is  true,  then  the  first  return  value  is  not used
    directly  but rather as if it was the `repl' parameter);
otherwise,  if  it  is  false  or  nil,  then  there  is  no
replacement  (that  is, the  original match  is kept  in the

Such a change may be helpful for interactive use, say, in text editor Replace operation, when the user specifies the `repl' string (e.g. "%2%1") and wants to make (or not to make) replacements individually for every match.