gsub alphanumeric and spaces how?

I want to clean a string of all non alphanumeric character, i am using this, which works great…
 

local msgLine=textMsg:gsub('%W','')

…but it removes all spaces…and i want to keep them…

i have tried : %W%s, [%W-%s]… but they dont work. I am getting the string from an input text…
Who can i make it works?

You can try ‘[^a-zA-Z0-9]’

This works great, but it removes all japanese characters for example…the text is an input text…so any people from any part of the world can write…how can i remove all non-alphanumeric, leaving spaces and foreigner languages?

Does your original sample allows things like Japanese characters? If so this probably works (’%s+%W’,’’)

From your variable names it looks like you are making a chat. For my game I’m using http://developer.coronalabs.com/code/utf-8-encode-and-decode

Before sending I encode it, on the client side I decode it, so far so good. Have you thought about something like that?

You can try ‘[^a-zA-Z0-9]’

This works great, but it removes all japanese characters for example…the text is an input text…so any people from any part of the world can write…how can i remove all non-alphanumeric, leaving spaces and foreigner languages?

Does your original sample allows things like Japanese characters? If so this probably works (’%s+%W’,’’)

From your variable names it looks like you are making a chat. For my game I’m using http://developer.coronalabs.com/code/utf-8-encode-and-decode

Before sending I encode it, on the client side I decode it, so far so good. Have you thought about something like that?