Need help with text handling (from wildcard in trigger)

Posted by Lerkista on Tue 09 Aug 2016 04:34 AM — 3 posts, 14,495 views.

#0
Hi

I want to make a trigger and do some actions depending the text, for example


Match: You see * in this room


But %1 can be any of this (for example):


a rat
an elephant
Sargent Lewis
Maria


how can i get that %1 be:


cat
elephant
Sargent Lewis


i mean, in the first two cases, eliminate the "a " and "an ", and let "Sargent Lewis" as is

otr other way is with two triggers:

One trigger that match:


"^You see (a|an) (.*?) in this room$


and works with the first 2 cases, but don't know what to do to match the last two

Something like get the name if not start with A and An

Any help??

Thanks
Australia Forum Administrator #1
How about this?


^You see (?:(?:a|an) )?(.*?) in this room$


The "?:" stops it being captured (so the name is still %1).

What this is looking for is "a" or "an" followed by a space, which itself is optional, preceding the word.

An alternative would be to have the space after each optional word, like this:


^You see (?:a |an )?(.*?) in this room$


And if you omit the "?:" then the matching word (eg. Maria) becomes wildcard #2. eg.


^You see (a |an )?(.*?) in this room$
#2
Hi

That works perfect

thanks