Home Forums General Programming Removing spaces from ASCII text Reply To: Removing spaces from ASCII text

#13710
lfo2vco
lfo2vco
Participant

OK, I have been trying to make this work and I found this:

-- trim whitespace from right end of string
function trimr(s)
return s:find'^%s*$' and '' or s:match'^(.*%S)'
end

I’m guessing this is related to the String Class Atom made reference to. This is how I got it to work in my method:

nameData = L(PatchLabel:getProperty("uiLabelText"))

function trim (s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end

nameTrim = (trim(nameData))
fileToWrite = utils.saveFileWindow("Save patch to disk", File(nameTrim), "*.syx", true)