To get the original player id just strip everything starting at "|". The shouldn't be a | in a player name if I'm correct.
You can use the lua string functions, especially
Lua Code:
local startDelimiter = string.find(s, '|')
To find the "|" delimiter.
And then substring to get the string from the start until the found "|" character.
Assuming the total string including the color codes is in a variable called "accountName":
Lua Code:
local accountName = string.sub(accountName , startDelimiter)
Maybe you need to male startDelimiter = startDelimiter -1 to strip the "|" character itsself. i'm not sure if the string.find function will give you the value before or including the "|"