I did change it to two triggers, one for beginning of line and one for end of line, I just wanted to do it with one is all.
Then I have no clue what the match all thing is and/or is for evidently.
Multiple matches on a single line
Re: Multiple matches on a single line
Does the tooltip explain it to you? I'll rephase it if it's not good enough
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Multiple matches on a single line
I've had it checked through the entire process. From what I could find of the /g option it returns an array, table in lua I'd imagine, so do I access it matches[2], matches[3], etc or is it in a multimatches? Guess that's where I'm confused.
Re: Multiple matches on a single line
It's matches[n+2..], yes. Just try display(matches)
But it's not applicable to your case. That option is for the regex patterns themselves, not the overall multi-pattern trigger.
But it's not applicable to your case. That option is for the regex patterns themselves, not the overall multi-pattern trigger.
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Multiple matches on a single line
Ok, got this far with some experimenting.
Reduced it to a single regex again and then just display(matches) to see what I got.
I can probably use similar code to what I already have just put it into a loop to select and color the replacements, just have to remember to reset them back to defaults. Is there a get the default fore/background color from settings?
Reduced it to a single regex again and then just display(matches) to see what I got.
Code: Select all
Diamante Ka'tath walks in.
table {
1: 'Diamante'
2: 'Diamante'
3: 'Ka'tath'
4: 'Ka'tath'
}
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Multiple matches on a single line
Alright, aside from how to capture a name in the plural (my MUD allows single quotes in player names) I've got it to work with a single regex.
Regex: ([A-Z]'{0,1}[a-zA-Z]+'{0,1}[a-zA-Z]+)
Regex: ([A-Z]'{0,1}[a-zA-Z]+'{0,1}[a-zA-Z]+)
Any ideas on how to get the regex NOT to match the 's in: Krys'lysk's freezing bite wounds you.
Re: Multiple matches on a single line
If someone won't be able to help you with a trigger, this will sanitize this for you - :gsub("'s$", "")
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Multiple matches on a single line
Reading string.gsub() now, thanks for all your help. I didn't understand that it was returning more elements in the matches array.
Any idea why it's doubling up in the matches table though?
Any idea why it's doubling up in the matches table though?
-
- Posts: 186
- Joined: Sun Nov 14, 2010 5:57 am
Re: Multiple matches on a single line
by changing a line to add in the string.gsub() fn it's fixed!!!!
Re: Multiple matches on a single line
It's not doubling up matches, it's just doing the usual practice:
1. complete first match 2. first capture group 3. second cap group ... n+1. complete second match on the line, n+2. first cap group of the second match etc.
So if you enable match all, the trigger engine fills matches[] with all matches and all capture groups of this lline and THEN runs the script.
1. complete first match 2. first capture group 3. second cap group ... n+1. complete second match on the line, n+2. first cap group of the second match etc.
So if you enable match all, the trigger engine fills matches[] with all matches and all capture groups of this lline and THEN runs the script.