[Geany-devel] Bug#561276: geany does not escape '\\' in replace string

Enrico Tröger enrico.troeger at xxxxx
Thu Dec 17 07:21:05 UTC 2009

On Wed, 16 Dec 2009 13:06:42 +0000, Ximin wrote:

>Damián Viano wrote:
>>> In "try to replace me with \t", with Find = "me":
>> This is the result with:
>> "Use regular expressions" ON
>> "Use escape sequences"    OFF
>>> Replace = "\t" replaces "me" with a tab
>>> Replace = "\\t" replaces "me" with a backslash followed by a tab
>>> Replace = "\\\t" replaces "me" with two backslashes followed by a
>>> tab
>> "Use regular expressions" ON
>> "Use escape sequences"    ON
>> Replace = "\t" replaces "me" with a tab
>> Replace = "\t" replaces "me" with a tab
>> Replace = "\\t" replaces "me" with a backslash followed by a tab
>- the above 2 examples are wrong; "\t" should be "\\t" and "\\t"
>should be "\\\t"
>Right, but what if you want to search for a regular expression, *AND*
>replace it with something containing the literal "\t"? The above
>examples cannot do this.
>In any case, if escape sequences are ON, then "\\" should be escaped
>to "\" regardless of whether regexp is on or not. Actually it should
>only an option for non-regexp; it should be implicitly ON when you use
>regexp, as is standard in every other implementation.

I had a short look at your examples but to be honest for me this is
just not that important. I surely can find more corner cases where the
one or the other regexp/special character combination won't work.
Either you write a patch to make things better or you maybe just use
tools which are more specialised for such tasks like grep, sed and

>I suggest using an already-made regexp library instead. Eg. libpcre,
>or the code from GNU grep (which does not have exponential
>corner-cases - see http://swtch.com/~rsc/regexp/regexp1.html).

You also said Geany were 'trying to implement its own regexp engine'.
This is wrong.
Geany uses the regexp implementation of Scintilla, the used editing
component. It's not as good as it could be but it does the job and it
doesn't pull in new, external dependencies like libpcre.
Please read the documentation to learn more about the use of regular
expressions within Find and Replace dialogs in Geany. There are some
limitations and differences but generally it just works.


Get my GPG key from http://www.uvena.de/pub.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20091217/1d000d8d/attachment.pgp>

More information about the Devel mailing list