Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ regexp problem
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Wyd
(14 posts) Bio
|
Date
| Mon 19 Jun 2006 05:03 AM (UTC) |
Message
| Hi all, my second question since I registered!
I have the following line I want to trigger on
You sense a connection between room1 and room2.
The problem is that room1 and room2 may contain multiply words, and the expression may extend over multiply lines...so for a more specific example:
You sense a connection between Twisted path past a dwarf tree (house) and
Gemstone vials of Moghedu.
or
You sense a connection between Southern Balcony (house) and River Zaphar
through forest.
Is there anyway to match this, or am I being to hopefull?
Thanks! | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #1 on Mon 19 Jun 2006 06:53 AM (UTC) |
Message
| The simplest thing is a multi-line trigger, which are notorious to get right, because of the possibility of multiple matches. This seemed to work for me from your examples:
<triggers>
<trigger
enabled="y"
lines_to_match="3"
match="(?s)^You sense a connection between ([^.]+) and ([^.]+)\.\Z"
multi_line="y"
regexp="y"
send_to="2"
sequence="100"
>
<send>Wildcard 1 = %1
Wildcard 2 = %2</send>
</trigger>
</triggers>
The wildcards may end up with newlines in them (because the text had a line break) but you can do a replace to get rid of those.
Example:
You sense a connection between Southern Balcony (house) and River Zaphar
through forest.
Wildcard 1 = Southern Balcony (house)
Wildcard 2 = River Zaphar
through forest
This matched OK, now by replacing the newlines by spaces in the wildcard you would get the room name without breaks in it.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Wyd
(14 posts) Bio
|
Date
| Reply #2 on Mon 19 Jun 2006 11:36 AM (UTC) |
Message
| Thanks for that.
One last question...if I create a trigger with a certain name, and then attempt to make another with the same name, will it overwrite the original one, cause me to have two triggers, or not create the second one?
| Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #3 on Mon 19 Jun 2006 05:35 PM (UTC) |
Message
| Using the GUI interface, or a script, you can't add a trigger of the same name, *unless* (in a script) you use the flag:
const eReplace = 1024 ' replace existing trigger of same name
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,139 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top