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.
The correct behaviour (iirc) is to escape "\" into ""; so that:
"Use regular expressions" OFF "Use escape sequences" ON
Replace = "\t" replaces "me" with a tab Replace = "\t" replaces "me" with the literal string "\t" Replace = "\\t" replaces "me" with a backslash followed by a tab
"Use regular expressions" OFF is kind of useless if I want to search for a regexp. geany should exhibit the above behaviour even if regexp is ON.
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).