WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Pattern matching (https://www.wowinterface.com/forums/showthread.php?t=46537)

Rainrider 05-24-13 12:58 PM

Pattern matching
 
I want to shorten mob names from say "Sun Weaver Archer" to "S. W. Archer". I use
Code:

string.gsub(name, "%s?(.[\128-\191]*)%S+%s", "%1. ")
which I found in an addon I use, but must admit I don't understand how it works. What is the .[\128-\191] part supposed to mean? '.' stands for a single character and the next part is a range of ascii codes from 128 to 191. I found out this is to make it work for non-English languages, as it doesn't work if I use
Code:

string.gsub(name, "%s?(%S)%S+%s", "%1. ")
.

The other problem I have is when I run this for name = "Echo of a Pandaren Monk", it would return "E. o. aP. Monk" (no space between a and P.). How would I fix this.

Would appreciate some explanations about this.

Phanx 05-24-13 08:23 PM

See here:
http://www.wowinterface.com/forums/s...ad.php?t=46497

Since that thread is about the same thing, any replies should be posted there, so the discussion stays in one place.

Rainrider 05-24-13 09:36 PM

Thanks for the pointer, Phanx. I only searched for "pattern matching" and the like and so I haven't found the other threat. I'll post there then.


All times are GMT -6. The time now is 11:33 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI