How to filter name rank

My group role name is [PREFIX] Rank Name
I want to get the prefix and rank name for the rank tag using filter

I guess you could do it like this:

local Role = '[PREFIX] Rank Name' -- get this through some other methods idk

local Split = string.split(Role, "]")
local Prefix = string.sub(Split[1], 2)
local RankName = string.sub(Split[2], 2)

print(Prefix) - - PREFIX
print(RankName) -- Rank Name 

Splitting it returns 2 seperate strings, split at the ]. String.sub is then used to change where the string starts from (baically just removes the first character) as it isn’t part of the prefix / name

Let me try this

for 30+ characters

I changed some and it works ty

local Role = '[OR-1] Recruit'

local Prefix, RankName = Role:match("%[(.-)%] (.+)")
Prefix = "[" .. Prefix .. "]"
print(Prefix)
print(RankName)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.