[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to highlight-regexp across multiple lines
From: |
Angus Comber |
Subject: |
Re: How to highlight-regexp across multiple lines |
Date: |
Fri, 4 Apr 2014 10:58:41 +0100 |
Strangely, this works better:
aPDU[^W]+[}]$
[^W] is definitely mystifying. Others eg [^some other letter] can work -
but only if your target block doesn't contain that letter. And some of
them don't work at all - puzzling.
Even then, its mysterious because in a fairly large log file I have ALL
aPDU's were highlighted correctly except this text where the selected text
was from the start of the first to the end of the second one.
aPDU-rose : invoke : {
invokeID 11,
operationValue local : 21,
argument {
crossRefIdentifier '40 2f'H,
eventSpecificInfo callEvent : connectionClearedEvent : {
droppedConnection {
call '02 01 19 0f'H,
device staticID : dialingNumber : "403"
},
releasingDevice deviceIdentifier : deviceIdentifier : dialingNumber :
"403",
localConnectionInfo connect,
cause normalClearing
}
}
}
-- monitor: 402
-- CSTA Fwk : set control party
-- setting cntrlDN=403 (for 1 parties)
-- event ignored
+++ Calls dump +++
1 connids, 1 threads, 1 calls
1:876002435e991001@2d8f990 2d8fc98:1[d403.2d90a08:1/EA-O
d402.2d91e28:2/EA-D]
--- Calls dump ---
18:36:28.116 --- Input ---
18:36:28.125 +++ Input +++
18:36:28.125 DataFromSwitch 14 bytes
0000-000d 00 0c a2 0a 02 01 1e 30 05 02 01 05 05 00 |.......0...... |
Decoded:
aPDU-rose : retResult : {
invokeID 30,
operValue {
operationValue local : 5,
result noData : NULL
}
}
On 3 April 2014 20:21, Thorsten Jolitz <tjolitz@gmail.com> wrote:
> Angus Comber <anguscomber@gmail.com> writes:
>
> > It seems that it matches the aPDU messages provided there is no 0 in the
> > text. I am puzzled by the [^\\000] - where can I find documentation on
> it?
>
> Thats stolen from the Org-mode sources, and I asked the same question
> before ;)
>
> Here is Carsten Dominik's answer:
>
>
> ,----------------------------------------------------------------------------
> | > PS
> | > Can anybody explain this marvelous construct in the regexp:
> | >
> | > ,---------
> | > | [^\\000]
> | > `---------
> |
> | This is just a cheep way to match any character at all, because \000
> should
> | not be part of any string (in C it indicates the end of a string).
> | In principle you could put any character you are sure will not turn up,
> | but \000 seems to be the safest choice. It is
> | faster (I think) than "\\(.\\|\n\\)*" because the first will
> | just run fast and streight with a table lookup while the
> | latter need to always alternate between two alternatives.
> | I have not timed it, though.
>
> `----------------------------------------------------------------------------
>
> > Is it not null or something like that? But then why does it not capture
> > string "0"?
>
> This happened to me to, although I think it shouldn't.
>
> But when I used it with M-x regexp-builder it worked. With M-x reb-copy
> (and then paste), the [^\\000] is transformed to a different
> representation - maybe you could try reb-copy & paste it into your
> function and see if it works then?
>
> > On 3 April 2014 16:08, Thorsten Jolitz <tjolitz@gmail.com> wrote:
> >
> >> Angus Comber <anguscomber@gmail.com> writes:
> >>
> >> > I was looking at this question on stackoverflow and it seems regex can
> >> > select across multiple lines generally but how would I do so for
> >> > highlight-regexp in emacs?
> >> >
> >> >
> >>
> http://stackoverflow.com/questions/159118/how-do-i-match-any-character-across-multiple-lines-in-a-regular-expression
> >> >
> >> >
> >> > Eg I want to highlight ALL text from aPDU... to the final closing
> brace:
> >> >
> >> > aPDU-rose : retResult : {
> >> > invokeID 2,
> >> > operValue {
> >> > operationValue local : 71,
> >> > result {
> >> > crossRefIdentifier '40 3f'H
> >> > }
> >> > }
> >> > }
> >> >
> >> >
> >> > How would I do that using highlight-regexp?
> >> >
> >> > highlight-regexp aPDU-rose.* hi-yellow would get me the first line -
> but
> >> > how to get everything including last } character?
> >>
> >> This regexp did match the aPDU in the gnus *Article* buffer:
> >>
> >> ,--------------------
> >> | "^aPDU[^\\000]+[}]+?$"
> >> `--------------------
> >>
> >> --
> >> cheers,
> >> Thorsten
> >>
> >>
> >>
> >
>
> --
> cheers,
> Thorsten
>
>
>
Re: How to highlight-regexp across multiple lines, Nicolas Richard, 2014/04/04