Thread Tools Display Modes
11-03-15, 10:30 PM   #1
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Matching pattern with words and apostrophes

I'm splitting strings into individual words to create an auto-completion dictionary, but my current code does not account for words with apostrophes in them.
I'd like the dictionary to store combinations such as "doesn't", "let's", etc.

I'm currently using the pattern "[%a][%w]+", which is perfectly fine for coherent words, but will cut words with apostrophes into parts.
__________________

Last edited by MunkDev : 11-04-15 at 12:41 AM.
  Reply With Quote
11-03-15, 10:37 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
"[%a][%w']*[%w]+" should match a word containing an apostrophe.
  Reply With Quote
11-03-15, 10:45 PM   #3
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by semlar View Post
"[%a][%w']*[%w]+" should match a word containing an apostrophe.
Thanks! Works like a charm! Kudos on the quick response, too.
__________________

Last edited by MunkDev : 11-03-15 at 11:12 PM.
  Reply With Quote
11-04-15, 11:52 AM   #4
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Question

Going to keep using this thread for pattern questions.

How can I remove texture sequences from a string?

How do I turn this:
Lua Code:
  1. HELP_OPTIONS_MOVED = "|TInterface\\OptionsFrame\\UI-OptionsFrame-NewFeatureIcon:0:0:0:-1|t  Colorblind and Move Pad options have been moved to the Accessibility section.";
  2. NPE_MAPCALLOUTBASE = "|TInterface\\WorldMap\\WorldMapArrow:28:28|t marks your location.\n\n";

...into this:
Lua Code:
  1. HELP_OPTIONS_MOVED = "  Colorblind and Move Pad options have been moved to the Accessibility section.";
  2. NPE_MAPCALLOUTBASE = " marks your location.\n\n";
__________________

Last edited by MunkDev : 11-04-15 at 11:55 AM.
  Reply With Quote
11-04-15, 12:08 PM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
There might be a better funciton, but this also works:

Lua Code:
  1. local substring = string.gsub("|TInterface\\OptionsFrame\\UI-OptionsFrame-NewFeatureIcon:0:0:0:-1|t  Colorblind and Move Pad options have been moved to the Accessibility section.", "|T.*|t", "")
  2. print(substring)
  Reply With Quote
11-04-15, 12:10 PM   #6
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Originally Posted by Resike View Post
Lua Code:
  1. local string = string.gsub("|TInterface\\OptionsFrame\\UI-OptionsFrame-NewFeatureIcon:0:0:0:-1|t  Colorblind and Move Pad options have been moved to the Accessibility section.", "|T.*|t", "")
  2. print(string)
That simple? Thanks.
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Matching pattern with words and apostrophes

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