I want to parse every word that could be a player killer: ([a-zA-Z']+)
This works fine IF their name is the first word on a line, so in the follow example Gnur's name will color and Kulek's will not:
Gnur is resting on a plush couch made of royal purple velvet.
(White Aura) Kulek is here.
I've checked the matches all box and really don't want to mess with string manipulation if I don't have to, but I'll probably have to for other reasons.
Multiple matches on a single line
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Multiple matches on a single line
Last edited by Yetzederixx on Sat Apr 23, 2011 10:24 pm, edited 1 time in total.
Re: Multiple matches on a single line
Yeah... our forums can't embed html yet. (they will if you find an addon to phpBB that allows it).
You did enable match all option? matches[] will then contain all matches (your script will be run once on it).
You did enable match all option? matches[] will then contain all matches (your script will be run once on it).
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Multiple matches on a single line
Well I figured out a way to grab it with the spell flags and get it to highlight by changing the pattern to: (?:\([\w ]+\) )*([a-zA-Z']+)
I really don't want to do multiple patterns on this trigger if at all possible as I'm worried about efficiency.
I really don't want to do multiple patterns on this trigger if at all possible as I'm worried about efficiency.
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Multiple matches on a single line
So I ended up going with two regex's. One to highlight the name if it's the first on the line or if it's first on the line after the spell flags, the other highlights the name if it's the last word on a line aside from punctuation. However, it will still not highlight if both of these things are true as it will only work on whichever pattern happens to match first.
For example I've colored everything red that gets colored
Central Hall of the Red Tower
[Exits: east south up down ]
A huge couch of plush, crimson velvet and silver embroidery sits here.
A fountain carved out of dark red marble trickles slowly with cold water.
(Hostile) Krys'lysk is here.
murder krys
Krys'lysk yells 'Help! I am being attacked by Kulek!'
Your magic mauls Krys'lysk.
Krys'lysk has a few scratches.
check
Kulek is here, fighting Krys'lysk.
Krys'lysk has a few scratches.
Regex 1: ([A-Z]'{0,1}[a-zA-Z]+'{0,1}[a-zA-Z]+)[?.!]{1,1}'{0,1}$
Regex 2: (?:\([a-zA-Z\s]+\) )*([A-Z]'{0,1}[a-zA-Z]+'{0,1}[a-zA-Z]+)
For example I've colored everything red that gets colored
Central Hall of the Red Tower
[Exits: east south up down ]
A huge couch of plush, crimson velvet and silver embroidery sits here.
A fountain carved out of dark red marble trickles slowly with cold water.
(Hostile) Krys'lysk is here.
murder krys
Krys'lysk yells 'Help! I am being attacked by Kulek!'
Your magic mauls Krys'lysk.
Krys'lysk has a few scratches.
check
Kulek is here, fighting Krys'lysk.
Krys'lysk has a few scratches.
Regex 1: ([A-Z]'{0,1}[a-zA-Z]+'{0,1}[a-zA-Z]+)[?.!]{1,1}'{0,1}$
Regex 2: (?:\([a-zA-Z\s]+\) )*([A-Z]'{0,1}[a-zA-Z]+'{0,1}[a-zA-Z]+)
Re: Multiple matches on a single line
Several ways to do this I think. Best one might be just to abstract this into a function and have triggers.
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Multiple matches on a single line
What I don't want to do is change the pattern to ^.*$ and then parse each line for names and then try to figure out how to either replace the names in color or rebuild each and every line with cecho.
It seems that the match all checkbox is basically doing nothing as it doesn't matter if it's checked or not it will only ever match/fire once per line.
It seems that the match all checkbox is basically doing nothing as it doesn't matter if it's checked or not it will only ever match/fire once per line.
Re: Multiple matches on a single line
'match all' means multiple matches of the same pattern per line - it doesn't deal with multi-pattern triggers at all. Don't do that, why won't having 2 triggers with the same script work?
Re: Multiple matches on a single line
I've tried that match all method for a colour trigger, and it does not work. IE, I've had to resort to a function adding temp triggers to highlight words.
EX:
Trigger - (All as substring)
1)hidden
2)shrouded
3)monolith
Check match all, and then check a colour.
If ALL of those words appear on the same line. Only the first one is actually matched/coloured. Is this proper? I thought it would be the OR trigger (multiline/and is not checked). Why is it not highlighting all occurances of each word?
EX:
Trigger - (All as substring)
1)hidden
2)shrouded
3)monolith
Check match all, and then check a colour.
If ALL of those words appear on the same line. Only the first one is actually matched/coloured. Is this proper? I thought it would be the OR trigger (multiline/and is not checked). Why is it not highlighting all occurances of each word?
Re: Multiple matches on a single line
match all means the regex /g flag. It's not for other types of triggers or other patterns within one
Re: Multiple matches on a single line
Ahh, alright. Thanks for clarifying that then.