Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-06-12, 04:52 AM   #1
Animor
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 136
Pattern matching and "player playing" status

Hello,

I've got two question I hope to get answers to:

1. I'm trying to match a pattern in strings that can come in two ways:
a. "Bases: 3 Points: 150/1600 ..."
b. "Points/Flags: 2 ..."

I want to get the 150 in case it's a string type 'a' (with ####/####). And in case there is no such pattern (type 'b'), I want to get the number - 2 in the example.
I've tried to use:
Code:
string.match(origString, "(%d+)/*")
But it didn't work - I got 3 for string type 'a'. If I use:
Code:
string.match(origString, "(%d+)/")
then I get the 150, but it obviously fails on string type 'b'.
Is there a matching pattern that will catch both cases? Note that the string before the number can alter, it's not always 'Points' for example.

2. When trying to whisper to an offline player, I get error "No player named XXX is currently playing". Is there a way to know that prior to the whisper? Like an API telling me that? I looked but couldn't find one.

Thanks
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Pattern matching and "player playing" status


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