|
masterkrueger Wanderer
Joined: 24 Jan 2010 Posts: 65 Location: Hamburg
|
Posted: Tue May 18, 2010 6:22 pm
Stringlist or RegExp in %pos? |
Hi, is it possible to assign a stringlist to match anything in the list in a string?
First i wanted to use regular expressions but i think this can't work.
The problem is i must find a changing substring like "Exet" and "Exit", tried "Ex?t"
but did not work, because i think its treated like a string and a normal questionmark
is interpreted.
{@Exits} as "Exit|Exet" did not work.
I think the next question i related to the first. I wanted to match a line for exit-keywords,
but not anything behind the keyword but specific words after the match like:
%match(%1, "Exits: (*)", @RExits)
Anything behind the Exits: is stored in the @RExits Variable but theres the problem,
the exit line says:
Exits: north, south AND east
I have a variable @directions=north|south|west..... in it.
How can i match only the real exits into the RExits variable?
Thanks ... @ MattLofton too ;) |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Tue May 18, 2010 6:44 pm |
In Regex \b[Exits\?]{4,5}\b is pretty close to what you want I think.
The problem I think you would run into is that it is too vague.
You could do it like this.
\b(?:Exit|Exet|Exits)\b |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
masterkrueger Wanderer
Joined: 24 Jan 2010 Posts: 65 Location: Hamburg
|
Posted: Tue May 18, 2010 7:05 pm |
Can i use it like this, or do i have to activate "Regular Expression" flag?
#if (%pos("\b(?:Exit|Exet|Exits)\b",%1)) {#echo "Exit found"}{#echo "nothing"}
I get no message, but the exit is there?! |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue May 18, 2010 7:12 pm |
To only match real exits (I'm not sure why this would be necessary, unless you need other scripts beyond your #TAG triggers to access exits), you will need to process the @Rexits variable:
Rexits = %replace(%replace(@Rexits," and ","|"),", ","|")
There's no way to pick out just the exits themselves among a comma-and-AND-delimited list via trigger pattern, as patterns (even REGEX) rely on continuous blocks of text to define match/no match. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
masterkrueger Wanderer
Joined: 24 Jan 2010 Posts: 65 Location: Hamburg
|
Posted: Tue May 18, 2010 7:20 pm |
Thanks, i'll take the "false" strings out. I need the rooms for the #TAG part :) with your help in the other post but i thought it is not a beta problem and i posted it here.
|
|
|
|
|
|