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
➜ Regex trouble
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Thu 25 Nov 2004 05:21 PM (UTC) Amended on Thu 25 Nov 2004 05:22 PM (UTC) by Poromenos
|
Message
| I know this is not MC per se, but I'm going crazy. Could someone please tell me why this matches "my page" for %1 and nothing for %2?
\[\[\[\?LINK(?:\|(.*?))+\]\]\]
The text is [[[?LINK|poromenos.org|my page]]] |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Thu 25 Nov 2004 06:38 PM (UTC) |
Message
| You have only one capturing sequence there. Round brackets capture, of which you have two sets, however (:? something) says not to capture. You have that in front of one of them. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #2 on Thu 25 Nov 2004 06:55 PM (UTC) |
Message
| That's not the problem, I want to capture the internal one. It always returns the last one, no matter how many I have, and even this won't work:
LINK(\|.+?)+\] |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 25 Nov 2004 07:56 PM (UTC) |
Message
| Hmmm, interesting. Take out the "ungreedy" question mark and it works better:
<triggers>
<trigger
custom_colour="2"
enabled="y"
match="\[\[\[\?LINK(?:\|(.*))+\]\]\]"
regexp="y"
send_to="2"
sequence="100"
>
<send>%%1 = %1
%%2 = %2</send>
</trigger>
</triggers>
My output for that one:
%1 = poromenos.org|my page
%2 =
Or for the second one do the same thing or add another set of brackets:
<triggers>
<trigger
custom_colour="2"
enabled="y"
match="LINK((\|.+?)+)\]"
regexp="y"
send_to="2"
sequence="100"
>
<send>%%1 = %1
%%2 = %2</send>
</trigger>
</triggers>
My output for that one:
%1 = |poromenos.org|my page
%2 = |my page
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Somegirl
(33 posts) Bio
|
Date
| Reply #4 on Thu 25 Nov 2004 08:08 PM (UTC) |
Message
| Will this always be a address|title?
if so, why not use LINK\|([a-zA-Z.]+)\|([a-zA-Z ]+)
| Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #5 on Thu 25 Nov 2004 09:10 PM (UTC) |
Message
| No, Somegirl, it has to be able to match any number of parameters. After talking to some Perl experts, I have found out that this can't be done, because it will always return the last match. I have finally found something regex can't do! :P |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #6 on Thu 25 Nov 2004 11:52 PM (UTC) |
Message
| Well, my solution works. The extra set of brackets around the whole thing. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Somegirl
(33 posts) Bio
|
Date
| Reply #7 on Fri 26 Nov 2004 10:30 AM (UTC) Amended on Fri 26 Nov 2004 10:32 AM (UTC) by Somegirl
|
Message
| Right! This is very similar to what I was trying to do in the other thread. Matching multiple things in the same line. You can only capture the last or first thing because it will only match once per line. What Nick did works because it basically captures the whole string then the %2 is a submatch on one thing inside the string. I've just settled on sending the whole line to scripting to get what I want.
Now a lot more of the crazy RegExp documentation included with Mushclient makes sense. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #8 on Fri 26 Nov 2004 09:35 PM (UTC) |
Message
| You can make it match multiple times on a line. But the script will only get called once.
Try coloring something multiple times on a line. It works. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | 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.
22,671 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top