Is there a way to find/replace parts of a text string when the string is a variable?
Ex.
“Hello, how are you?” to “Hello,_how_are_you?”
Thanks! [import]uid: 150151 topic_id: 33791 reply_id: 333791[/import]
Is there a way to find/replace parts of a text string when the string is a variable?
Ex.
“Hello, how are you?” to “Hello,_how_are_you?”
Thanks! [import]uid: 150151 topic_id: 33791 reply_id: 333791[/import]
Yes, though you might want to read up on the language to cook up your own specific interpretation. Start reading here:
http://lua-users.org/wiki/StringLibraryTutorial [import]uid: 8271 topic_id: 33791 reply_id: 134309[/import]
Easy answer - string.gsub() will do this; http://developer.coronalabs.com/reference/index/stringgsub
Run this sample;
[lua]string1 = “This is a string”
string2 = string.gsub(string1, " ", “_”)
print (string2)[/lua]
Peach
[import]uid: 52491 topic_id: 33791 reply_id: 134311[/import]
string.gsub() was the peftect solution! Thank you!!! [import]uid: 150151 topic_id: 33791 reply_id: 134487[/import]
Yes, though you might want to read up on the language to cook up your own specific interpretation. Start reading here:
http://lua-users.org/wiki/StringLibraryTutorial [import]uid: 8271 topic_id: 33791 reply_id: 134309[/import]
Easy answer - string.gsub() will do this; http://developer.coronalabs.com/reference/index/stringgsub
Run this sample;
[lua]string1 = “This is a string”
string2 = string.gsub(string1, " ", “_”)
print (string2)[/lua]
Peach
[import]uid: 52491 topic_id: 33791 reply_id: 134311[/import]
string.gsub() was the peftect solution! Thank you!!! [import]uid: 150151 topic_id: 33791 reply_id: 134487[/import]