[Geany-Users] Find, regex, spans lines

Colomban Wendling lists.ban at xxxxx
Thu Jul 31 18:27:46 UTC 2014

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?


> 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.

> 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]


More information about the Users mailing list