lua-users home
lua-l archive

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


http://www.php.net/manual/en/function.addslashes.php

	You should try:

-- Preffix with slashes (Sybase off)
function addslashes(s)
	return (string.gsub(s, '([\'\"])', '\\%1'))
end

-- Double quote instead of preffixing with slashes (Sybase on)
function addslashes(s)
	return (string.gsub(s, '([\'\"])', '%1%1'))
end


--  First function (slashes)
--~ print(addslashes("Testing some 'quoted' text"))
--> Testing some \'quoted\' text


--  Second function (double quotes)
--~ print(addslashes("Testing some 'quoted' text"))
--> Testing some ''quoted'' text


--rb