help-gnu-emacs
[Top][All Lists]
Advanced

[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 13:50:50 +0100

It works fine using re-builder as Thorsten explained.  Mine looks like this
in re-builder pane:

"aPDU[^^@]+?
}
"

But that gave me the hint - the [^^@]

Now this works perfectly:

(highlight-regexp "aPDU[^^@]+[\}]$" (quote hi-yellow))

I am thinking this means aPDU followed by anything that is not a null
character (ie EVERYTHING) followed by }\n

I am still a little puzzled though because I have multiple closing braces
followed by linefeeed in the aPDU's.  But anyway, it works!



On 4 April 2014 11:49, Nicolas Richard <theonewiththeevillook@yahoo.fr>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:
>
> interactively, you enter the string it as follows:
> a P D U [ ^ C-q 0 RET ] + C-q C-j } RET
>
> in elisp it gives:
> (highlight-regexp "aPDU[^\000]+?\n}" (quote hi-yellow))
>
> C-q 0 RET inserts a character which has '0' as octal (or whatevervalue
> read-quoted-char-radix is) representation, that's the NUL character that
> Thorsten mentionned. This is equivalent to "\000" in elisp.
>
> C-q C-j inserts a new line character (simply hitting RET would terminate
> the prompt, so that's not an option). This is equivalent to "\n" in elisp.
>
> The idea is : highlight *everything* lazily from the string "aPDU" up to
> the first sequence "newline-closing brace".
>
> HTH,
>
> --
> Nico.
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]