Very Basic Help Needed
Very Basic Help Needed
I'm going to have a bunch of these, so I'll ask your forbearance in advance. I'm brand new to coding and sort of floundering here.
I've been trying to do highlights on a line that contains a certain amount of unknown text, but the highlight switch seems to only highlight the (.*) part.
Trigger:
^You have slain (.*).$
where the (.*)could be whitespace and up to 4-5 words, and only that will get highlighted leaving the "You have slain" alone.
I've tried turning that off, and putting in some stuff into the script box that I found in some threads that sounded like it should work, but to no avail.
selectString(line, 1)
fg("red")
resetFormat()
I'm sure the answer is really easy, but I've literally been reading threads and looking in the manual for a half hour and can't for the life of me figure it out. Eventually I want to make a script for hunting that will use the trigger to make me pick up the corpse when I next get balance, but if I can't even get this to work...
Re: Very Basic Help Needed
If you want the whole line highlighted with RegEx type then you'll need to use scripting instead of the built-in 'trigger highlight' from Mudlet. Its apparently a 'feature' that only the captured group is highlighted....
Create your trigger, Regular expression type:
In the script, to highlight the whole line use :
The highlighting will not work, if obviously the trigger line does not match, or if the trigger is not enabled/not of the Regular Expression type.
Create your trigger, Regular expression type:
Code: Select all
^You have slain (.+?)\.$
Code: Select all
selectString(line,1)
fg('red')
resetFormat()
Re: Very Basic Help Needed
Yeah, it's a feature - you can still put brackets around the whole thing if you'd like it highlighted.
Otherwise, this great feature is useful for seeing what is your pattern capturing, without any code, and juxtaposed onto the line itself!
Otherwise, this great feature is useful for seeing what is your pattern capturing, without any code, and juxtaposed onto the line itself!
Re: Very Basic Help Needed
Tired, so I must be doing something wrong, but that doesn't seem to work for me.
I'll give it another look in the morning.
Thanks for the help and patience so far!
I'll give it another look in the morning.
Thanks for the help and patience so far!
Re: Very Basic Help Needed
You can use the standard highlight feature just by matching the whole triggers. Remove the "()" from you trigger.
This works for me and highlight the whole line.
^You have slain (.*)$
to
^You have slain .*$
This works for me and highlight the whole line.
Re: Very Basic Help Needed
Gilmo:
That highlights the whole line, but then defeats the purpose of capture groups for RegEx. You'd be better off using a substring match in that case.
Vadi:
showCaptureGroups() isn't exactly a hard line to type to .. well, highlight the individual captures!
That highlights the whole line, but then defeats the purpose of capture groups for RegEx. You'd be better off using a substring match in that case.
Vadi:
showCaptureGroups() isn't exactly a hard line to type to .. well, highlight the individual captures!
Re: Very Basic Help Needed
That will only match the substring you put in.Rakon wrote:Gilmo:
That highlights the whole line, but then defeats the purpose of capture groups for RegEx. You'd be better off using a substring match in that case.