Problem with a regular expression

Posted by Indiana on Mon 06 Dec 2004 12:59 PM — 7 posts, 21,723 views.

Romania #0
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

H:3338 M:2036 [psdb eb]


(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:

H:3338 M:2036 [eb]


and works just fine.

The problem appears when it has to trigger

H:3338 M:2036 [p eb]


(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.
Australia Forum Administrator #1
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|\-)\]

Romania #2
Hmm .. no, that wasn't a problem since a line like
H:3338 M:2036 [ b]
(without that space there, yes)
can't even exist ...
H:3338 M:2036 [-b]

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
H:3338 M:2036 [p eb]

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)
Amended on Mon 06 Dec 2004 06:50 PM by Indiana
Australia Forum Administrator #3
It matches for me. Are you sure it's not matching? I have it set to colour the line, and it colours it.
Romania #4
Well, that is the problem .. it doesn't. And I have no idea why.
Romania #5
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.
USA #6
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.