Reply
Thread Tools Display Modes
Unread 05-24-13, 12:58 PM   #1
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 317
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.
Rainrider is offline   Reply With Quote
Unread 05-24-13, 08:23 PM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,376
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.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 05-24-13, 09:36 PM   #3
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 317
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.
Rainrider is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » Pattern matching

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off