|
rabek Beginner
Joined: 24 Nov 2011 Posts: 13 Location: United States
|
Posted: 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 )? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
rabek Beginner
Joined: 24 Nov 2011 Posts: 13 Location: United States
|
Posted: 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.
|
|
|
|
genemartin Newbie
Joined: 14 May 2020 Posts: 1
|
Posted: 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! |
|
|
|
|
|