SpecT Posted April 7, 2015 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
Moderators IIYAMA Posted April 7, 2015 Moderators 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) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Addlibs Posted April 7, 2015 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, " - ") Previously known as MrTasty.
SpecT Posted April 7, 2015 Author 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
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