SpecT Posted April 7, 2015 Share Posted April 7, 2015 (edited) Hello guys! So I'm working on a music panel and I wanted to know if it is possible to do something. Hope you will understand it! Example (song name): Someone ft. someone - The someone song Is it possible to get the text before the "-" and after the "-" ? Thanks in advance guys! Edited April 7, 2015 by Guest Link to comment
Moderators IIYAMA Posted April 7, 2015 Moderators Share Posted April 7, 2015 -- for lua demo -- local outputChatBox = outputChatBox or print -- url: [url=http://www.lua.org/cgi-bin/demo]www.lua.org/cgi-bin/demo[/url] --------------------- local namePart1 = "Someone ft. someone" local namePart2 = "The someone song" local songName = namePart1 .. " - " .. namePart2 outputChatBox(songName) Link to comment
Addlibs Posted April 7, 2015 Share Posted April 7, 2015 Splitting the string: local songname = "Someone ft Someone else - Song name" local beforeHyphen = gettok(songname, 1, " - ") local afterHyphen = gettok(songname, 2, " - ") Link to comment
SpecT Posted April 7, 2015 Author Share Posted April 7, 2015 Splitting the string:local songname = "Someone ft Someone else - Song name" local beforeHyphen = gettok(songname, 1, " - ") local afterHyphen = gettok(songname, 2, " - ") Thanks MrTasty!!! That's what I actually needed. But it returns: beforeHyphen = Someone afterHyphen = ft FIXED IT .. For these who need it too: local songname = "Someone ft Someone else - Song name" local beforeHyphen = gettok(songname, 1, 45) local afterHyphen = gettok(songname, 2, 45) 45 = "-" I used this >>https://wiki.multitheftauto.com/wiki/ASCII Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now