Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
rabek
Beginner


Joined: 24 Nov 2011
Posts: 13
Location: United States

PostPosted: Mon Apr 13, 2020 10:12 am   

Wildcards too greedy
 
Not sure how active this place is these days, but I'm hoping I can find some help.

I have a trigger I want to trigger off a line that looks like this:

some potent ground mountain bloom (in a purple leather pouch) (x10)

I have another trigger I want to trigger off a line that looks like this:

some average ground red-tinged deep green bloodwort (in a purple leather pouch stamped with swirling leaves)

They are effectively the same, except one has a count of items and the other does not, as it's a single item.

The problem is this:

($hName:*) ~(in *~)$

Matches with both, because * is too greedy and won't stop at the first ). As the container in the () could be anything and any number of words, I can't figure out how to match without using *. How do I make * less greedy so it stops at the first )?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Mon Apr 13, 2020 11:29 am   
 
First, you are using an end of line anchor ($), which is forcing it to be extra greedy.
We don't need that, as then it won't fire after tightening; when it has a count

To tighten up the pattern I suggest using a range []

($hName:*) ~([%w%s]~)
_________________
Discord: Shalimarwildcat
Reply with quote
rabek
Beginner


Joined: 24 Nov 2011
Posts: 13
Location: United States

PostPosted: Mon Apr 13, 2020 1:06 pm   
 
Excellent, thank you very much. The $ was a left-over from trying a few different methods to solve the problem. This is a problem that's come up a lot and I've always had to figure a way to work around; thank you very much for providing a much simpler and more elegant solution.
Reply with quote
genemartin
Newbie


Joined: 14 May 2020
Posts: 1

PostPosted: Thu May 14, 2020 2:25 am   
 
shalimar wrote:
First, you are using an end of line anchor ($), which is forcing it to be extra greedy.
We don't need that, as then it won't fire after tightening; when it has a count

To tighten up the pattern I suggest using a range []

($hName:*) ~([%w%s]~)

Thanks so much for your help!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net