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
➜ Problem with a regular expression
|
Problem with a regular expression
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Indiana
Romania (5 posts) Bio
|
| Date
| Mon 06 Dec 2004 12:59 PM (UTC) |
| Message
| I use this little trigger in order to extract some informations from the status:
^H\:([0-9]+) M\:([0-9]+) [(p?)(s?)(d?)(b?)([ ]?)(e|\-)(b|\-)]
A normal line it should match should be:
H:3338 M:2036 [ps eb]
A young rat wanders back into its warren where you may not follow.
The full syntax would be
(p,s,d,b) at the beignning can appear or not - if any of them appears, a space is inserted before the (e,b) group. The (e,b) group works a bit differently, that means that they control balance and equilibrium, so "e" means you have eq. "-" means you don't, pretty much the same for balance.
Still, it can be only alone on a line like above or:
H:3338 M:2036 [p eb] A young rat wanders back into its warren where you may not follow.
I tried the trigger above with:
and works just fine.
The problem appears when it has to trigger
(with no additional characters after the text above)
The funny thing is that if you add _anything_ after it, everything's ok, same if you put "-" instead of the "e".
Now, if anyone has any idea where I am doing wrong with this trigger or why Regexp acts so strange, I would apreciate the help.
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Mon 06 Dec 2004 06:31 PM (UTC) |
| Message
| For me, the line:
H:3338 M:2036 [p eb]
matched, however I can see problems with a line like:
H:3338 M:2036 [b]
Your trigger would match the first "b" (probably) as you have made the space optional. What I would do is put the space into a group, along with psdb, so if it finds any of those, it must find the space. See below. I have put a non-optional space after the 4 letters, but then made the whole group optional (? after the round bracket).
^H\:([0-9]+) M\:([0-9]+) \[((p?)(s?)(d?)(b?)[ ])?(e|\-)(b|\-)\]
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Indiana
Romania (5 posts) Bio
|
| Date
| Reply #2 on Mon 06 Dec 2004 06:46 PM (UTC) Amended on Mon 06 Dec 2004 06:50 PM (UTC) by Indiana
|
| Message
| Hmm .. no, that wasn't a problem since a line like
(without that space there, yes)
can't even exist ...
at most.
Anyway, it doesn't have any problem with that.
The problem is with:
H:3338 M:2036 [p eb]
With a flick of its small whiskers, a young rat dashes out of view.
That means when
is on a single line with nothing after it.
(your trigger as well fails to match the line above, at least with my 3.56, also with 3.50) | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Mon 06 Dec 2004 06:54 PM (UTC) |
| Message
| | It matches for me. Are you sure it's not matching? I have it set to colour the line, and it colours it. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Indiana
Romania (5 posts) Bio
|
| Date
| Reply #4 on Mon 06 Dec 2004 06:57 PM (UTC) |
| Message
| | Well, that is the problem .. it doesn't. And I have no idea why. | | Top |
|
| Posted by
| Indiana
Romania (5 posts) Bio
|
| Date
| Reply #5 on Mon 06 Dec 2004 07:03 PM (UTC) |
| Message
| Ok, interesting, I've solved the problem .. it seems that my regexp was ok, the real problem was with the sequence.
I had some old triggers that seemed to be parsed before my new trigger (both had the sequence 100).
Changed the sequence for the new one to 10 and now everything's ok. | | Top |
|
| Posted by
| Flannel
USA (1,230 posts) Bio
|
| Date
| Reply #6 on Mon 06 Dec 2004 07:41 PM (UTC) |
| Message
| You can also check "keep evaluating" on the other triggers, that should solve your problem.
Well, if you need to have your sequence back where it was. Changing the sequence (obviously) will work as well. |
~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.
20,515 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top