|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: Wed Jan 28, 2009 2:32 pm
Help with catching multi-lines with a regex trigger |
I'm having trouble catching multiple lines in some instances, the code is here:
Code: |
\#K\%(?:@mipcode)(?:@strlen)(@miptag)(?mipstring:(?:.|$|^|\s){@miplen,@miplen})((?:.|$|^|\s)*)
|
It will match something like:
Quote: |
#K%35532014DDDse ne n s e>On the brink of nothingness (se,ne,n,s,e)
|
Basically the code works by having a unique code, in this instasnce 35532, the next 3 digits are the string length following, 014, the next 3 are unique identifiers relating to informating after to like hpline, chatlines, ect. So the next 11 characters after the DDD will be identified as room exits. Then what is left will be captured, the beginning MIP stuff gagged, and the >On the brink... output. However, when I have a line like:
Quote: |
#K%35532162BAB~Sput~this doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't work#K%35532163BABx~Sput~this doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't workthis doesn't work>
|
it won't work. I'm thinking it has to do with not catching the newlines, but when i added $,^, and \s to the regex pattern it still fails. Is this buggy behavior or am I doing something wrong, any suggestions? Also, there are 2 miplines shown above, this is normal to happen, and I deal with them by having the part after the first mip pattern output again with #show so the triggers will keep parsing the #show until no mip patterns remain |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Wed Jan 28, 2009 4:09 pm |
I think you're looking for the \b "word boundary" metacharacter.
The other thing is the repeat within line check box in the trigger options. (Although this can be SLOW, so be careful.)
Edit: In the burst of inspiration that comes with hitting the post button, if a line will always have either a code at the beginning (followed potentially by some codes in the middle) or NO codes, you could work around some of the speed issues (I think) by having a trigger which matches only a code at the very beginning, and then a reparse with the repeat within line box which checks all the way through. |
|
|
|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: Wed Jan 28, 2009 10:26 pm |
I'll give it a shot when I get home, but atm I use 2 triggers to match it with priorities 1 then 2. Basically I do this since with regex the quantifiers (?mipstring:(?:.|$|^|\s){@miplen,@miplen}), @miplen is compiled at runtime, so you can't use a backreference. So the first trigger takes the string length, variable named strlen, subtracts 3, and sets that as the miplen. 3 is subtracted because the DDD/FFF/BAB tag is included in the number of characters following the string length parameter. Then the next trigger will parse it with the variables set correctly. I actually found that the repeat within line box last I tried made the pattern not match anything at all. Anyways, I'll give the /b a go and hopefully it works, thanks.
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|