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
➜ Bug reports
➜ Triggers and Colour-Matching
|
Triggers and Colour-Matching
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Hve
Germany (11 posts) Bio
|
| Date
| Sun 20 Apr 2003 04:41 PM (UTC) |
| Message
| There seems to be something wrong with triggers and colour-matching (or with my understanding of it).
Given the MUD output
| Georg Gast1, der Avalon-Besucher. [Foo] |
| Bengel Otto Ooops, der neutrale Mann [Bar] |
| Elfensproessling Eleila, die neutrale Elfe [Blork] |
I wanted a trigger to match the names (i.e. the bold stuff) in each line.
I tried
A)
<trigger
bold="y"
enabled="y"
group="test"
keep_evaluating="y"
make_italic="y"
match="([A-Z][a-z1-9]+),"
match_bold="y"
match_text_colour="y"
regexp="y"
send_to="2"
sequence="100"
text_colour="15"
>
<send>%1</send>
</trigger>
That's a straightforward trigger essentially with match="([A-Z][a-z]+)" and match_bold="y"
From the output and italicization, I conclude that
this matches on the first line:
Georg
Gast (of course without the '1')
Avalon
Besucher
Foo
although the latter three are not even near a bold char
(and only the first match gets sent to output).
And it matches nothing on subsequent lines.
B)
The same with match="([A-Z][a-z1-9]+),":
Matches
Gast1 (without 'Georg' of course)
Oops (without 'Otto')
Eleila
OK, at least now the subsequent lines are evaluated against the regexp.
C)
The same with match="([A-Z][a-z1-9 A-Z]+),"
or "([A-Z][\w ]+),"
This matches
Georg Gast1
on the first line and nothing on the other lines??
My version is 3.38.
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Mon 21 Apr 2003 01:45 AM (UTC) |
| Message
| You have a number of problems here. :)
Your first example, to match on "Georg Gast1" will not match because the regular expression does not allow for spaces, or capitals, inside the word.
So, you would need to match on something like:
([A-Z][A-Za-z1-9 ]+),
Note space after the "9".
As for the bold characters, how trigger matching works is that first the regular expression is evaluated, and then the result is tested to see if the first matching character has the specified boldness, colour, etc.
In your case of "Bengel Otto Ooops," assuming you fix up the problem with the space and capital "O"s, you will have a match on "Bengel Otto Ooops" which will then be rejected because Bengel is not bold, and white.
All I can suggest is, match on the name with what I assume is a title, (eg. Elfensproessling), and then in a script, omit the titles from a list of known ones.
Alternatively, once you have a general match (eg. you might have "Bengel Otto Ooops") call a script that uses GetStyleInfo to iterate through the line, looking for style runs. You can then check each style run to see if it is bold or not. Omit the non-bold ones, and you will be left with the name. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Hve
Germany (11 posts) Bio
|
| Date
| Reply #2 on Mon 21 Apr 2003 11:39 AM (UTC) |
| Message
| > So, you would need to match on something like:
>
> ([A-Z][A-Za-z1-9 ]+),
>
> Note space after the "9".
This looks like my version C.
I was not only concerned how to match a multi-word name,
but also with the problem that this regexp *does* match Georg Gast1 on the first line while it *does not* match Otto Ooops on the second line.
Apparently, the regexp matches "Bengel Otto Ooops," and then fails on the colour test. What I expected was that the regexp would backup and try "Otto Oops," afterwards (with matching colour this time). :(
But my other observation really seems to hint for a bug:
My first version (which ignored digits and spaces) did not find
"any occurence of one capital plus some small letters, starting in bold, on any line". Instead, it found "any occurence of one capital plus some small letters, provided the first such occurence on a line starts in bold".
It looks like the colour check is not made on the complete set of matches.
It might turn out handy if one could handle colour matching by means of assertions, e.g. something like
(?<![:BOLD:])(?[:BOLD:])foo
would match foo if it starts in bold and follows something non-bold - just a suggestion. Or one might have an option that includes ANSI sequences in the subject. Well, I must admit that all these suggestions would require some deep digging in the regexp code, which might adversely affect speed after all. Therefore, I invite You to ignore my suggestions :)
As of now, I'm trying to avoid colour matching in this case: Although the titles are quite numerous, they are but quite regular (i.e. usually one word, whereas all multi-word titles start with a special word). Therfore, the following currently suits me (with %3%4 being the name):
"^ \| (Ehrwuerdige.? |)([A-Za-z-]+ )?([A-Z][a-z0-9]+)( [A-Z][a-z0-9]+)?[, ]"
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Mon 21 Apr 2003 08:43 PM (UTC) |
| Message
| What I was trying to say is that there are really two processes here:
The trigger matching, which uses a third-party subroutine PCRE (Perl-Compatible Regular Expressions) which matches purely on text.
After a match, MUSHclient then does a check on whether the first character of the matched text passes various other tests, if required, such as bold text. It can't really "back up" and re-match the text and try again.
You might just as well argue that the test fails if the first character is bold and the second isn't.
My suggestion, which is the only one that will work here, is to make a broad match with the pure text, and then refine the match in a script if the only distinguishing thing is boldness. |
- 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.
15,405 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top