Jump to content

[SOLVED] Question about text


SpecT

Recommended Posts

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 by Guest
Link to comment
  • Moderators
-- 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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...