View Single Post
10/15/23, 08:10 AM   #6
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,579
Originally Posted by sinnereso View Post
this seems to be working so far:

Code:
victomCharacterName = victomCharacterName:sub(victomCharacterName:find("^[%w ]+"))
im no expert on other languages but my goal is to keep only alphanumeric and spaces from left to right which will filter out the ^Mx etc. Giving this a whorl a bit here to see if I get the rare error.

EDIT: Still gettin the random error.. ill have to revert back to stock CHARACTER NAME^Mx chat output for now until I get get it sorted. I thought I was gonna be a simple fix.
The pattern you used is fine as long as the input string contains the character sequence in question. But as I said, as soon as it doesn't, you will receive an error. There is no other pattern you can use that will fix that. As I explained, you will need to properly handle the case where find does not return anything instead.

In other words, you are making assumptions about the input value that do not seem to hold true. EVENT_PVP_KILL_FEED_DEATH can and will return character names that do not include ^Mx or ^Fx at the end.
  Reply With Quote