[texworks] Regex challenges
Stefan Löffler
st.loeffler at gmail.com
Fri Apr 10 16:28:01 CEST 2009
On 2009-04-10 16:00, Joseph Wright wrote:
>>> 2) In a DTX, comments in the explanation part start ^^A. This is easy to
>>> match with \^\^A, but that matches even in the code blocks. Ideally,
>>> I'd like:
>>> - If the line start %, comment = ^^A
>>> - If the line starts without %, comment = %
>>> but only colouring from the start of the comment, not the start of the
>>> line. Is this doable at all?
>>>
>> I can't think of a way to do this.
>>
>
> Ah well: I just wanted to be sure I'd not missed anything obvious.
>
I guess this could be achieved by lookbehind assertions (?<=...). I'm
not sure if they are supported by QRegExp, however (lookahead assertions
are explicitly mentioned in the documentation, but lookbehind assertions
are simply omitted). You'd have to try it out to see if it works. Maybe
something like
(?<=\n%.*)^^A.*
(Note: This will fail on the first line (since it doesn't start with a
\n) and may have other flaws. But it could get you started)
If this doesn't work, you could try
(?<=a).
This should match any character that is immediately preceded by an 'a'.
If this doesn't work either Qt probably doesn't support lookbehind
assertions.
HTH
Stefan
More information about the texworks
mailing list