View Single Post
01-08-11, 01:45 AM   #5
Xinhuan
A Chromatic Dragonspawn
 
Xinhuan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 174
strsplit()'s first argument must be 1 character long. If it is longer than 1 character, then ANY of the characters are treated as a delimiter. In your example

Code:
local realm, name = strsplit(" - ", UIDropDownMenu_GetText(CFM_LoadBox))
The delimeter you provided is basically " " or "-" (with " " repeated). So if you're splitting "Blackwing Lair - Chaosinc", then you end up getting the following returns:

Code:
"Blackwing", "Lair", "", "", "Chaosinc"
There are 2 empty strings there because there is nothing between " " and "-", and the second one is between "-" and " ".

If you are splitting "Barthilas - Xinhuan" then you basically get

Code:
"Barthilas", "", "", "Xinhuan"
Hence in your example code, your realm is correct, but your name is an empty string.

What you really want is this

Code:
local realm, name = string.match("Blackwing Lair - Chaosinc", "(.+) %- (.+)")
__________________
Author of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, GatherMate2, Routes and Cartographer_Routes
  Reply With Quote