[Geany-Users] Find, regex, spans lines

Lex Trotman elextr at xxxxx
Fri Aug 1 01:00:14 UTC 2014

On 1 August 2014 04:27, Colomban Wendling <lists.ban at herbesfolles.org> wrote:
> Le 31/07/2014 19:52, Péter a écrit :
>> When I issue a Find, with regular expression like "[^Q]*Q", Geany
>> behaves strangely: the highlight (the string found) spans many lines.
>> The "[^Q]*" matches as if the lines were joined.
>> (The search is *not* line-based.)
>> Do you experience the same?
> Yes
>> Why does geany behave like this?
> For technical reasons, and because although I started some work for
> line-based RE support, I didn't finish it (yet).
> If you're interested in the technical reason, it's quite simple: we use
> a multiline-capable regex engine and we pass it a pointer to the whole
> buffer instead of feeding it line-by line -- hence allowing it to
> perform multi-line matches.

And thats the right thing to do IM(NS)HO.

To make searches anchored to lines you need to explicitly us the
anchors ^ and $, and to facilitate this we set MULTILINE mode by
default though you can set flags in the regex (?m).


>> How to alter this behaviour?
> First, let's see why it doesn't already do what you want:  even though
> the DOTALL option is not enabled (which means "." won't match a
> newline), you can match newlines (e.g. with "\n").  But as you use a
> "not" range (anything but "Q"), and newline are not part of this range
> (they admittedly aren't "Q"s), they get included.
> So, to work this around, use "anything but Q or newline": [^Q\r\n]
> Regards,
> Colomban
> _______________________________________________
> Users mailing list
> Users at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/users

More information about the Users mailing list