Thread: String strip
View Single Post
01-31-15, 03:41 AM   #7
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Choonstertwo View Post
You could use a slightly less restrictive pattern that matches everything after the first dash:
lua Code:
  1. ("PLAYERNAME-Aggra(Português)"):gsub("%-.+", "")

You could also use the WoW-specific strsplit function:
lua Code:
  1. (strsplit("-", "PLAYERNAME-Aggra(Português)", 2))

Note the extra set of parentheses to discard all return values except the first.
The reason i used the %a+ pattern because sometime i also have to handle string like this:

"PetName-ServerName <OwnerName-ServerName>"

I havn't tried the built in strsplit but i don't think it would make a difference, usually the default Blizzard functions handle utf8 stuff even worse.
  Reply With Quote