Quantcast Pattern matching - WoWInterface
Thread Tools Display Modes
05-24-13, 12:58 PM   #1
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 395
Pattern matching

I want to shorten mob names from say "Sun Weaver Archer" to "S. W. Archer". I use
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
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.
  Reply With Quote
05-24-13, 08:23 PM   #2
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,567
See here:

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, oUF_Phanx, 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!
  Reply With Quote
05-24-13, 09:36 PM   #3
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 395
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.
  Reply With Quote

WoWInterface » 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