New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When replacing text if your replace string includes \b it inserts a backspace (as well as some other escape characters) #197
Comments
This problem is a result of a change made in 2011 to fix problem report 100 in the old google code issues. The original problem report was the user could not insert a newline in the replacement text, it would always insert the string literal "\n". Now we have the opposite problem: the user wants to insert the string literal, but the code is converting it to an escape sequence. You could argue that no one would want to insert a backspace character, but that still leaves the new line, carriage return, and tab escape sequences. I'm thinking that the best fix would be to treat the escape sequences as string literals: for example, the string C:\test\new\bin would be inserted as shown, without inserting a tab, newline, and backspace. Then, if the user wanted a tab, newline or other escape sequence, they would use a double backslash: \t \n \r, etc. (then, of course, this would mean you cannot insert a string literal of '\n'). We would add this to the tooltip on the "Replace with" field on the UI to help with the syntax. Any comments on this? |
I vote for literal strings. Regex mode already handles tab, newline, etc. If there's a big demand for non-regex special chars, we can cross that bridge when we get to it. |
Oh, are we talking about regex mode? Maybe I read this too quickly. |
The problem is in the replace, not in the search, and it affect both Regex and Text searches. To see the problem,
|
Right, current plain-text replace behavior is wrong. I think it should not support escape characters. That's what regex is for. Plain-text replace does already support newline (via multiline mode) and tab (have to paste it in, room for improvement). Regex escape sequences mean you have to double the slashes in the example. That's good and correct. It's regex. We could add a third option for "plain text but with escape chars", like Notepad++ does. |
Also, I wrote that without trying it out (at work) 😉 If doubling the slashes doesn't work for regex, then I think it's a bug. |
…extra backslash to insert special characters
From Justin....@gmail.com on August 07, 2013 09:01:08
What steps will reproduce the problem? 1. Create a text file with some text
2. Enter search string that will match text in that file
3. Replace with C:\test\bin What is the expected output? What do you see instead? Expected output: C:\test\bin
Actual output: C:\test(backspace character)in What version of the product are you using? On what operating system? v2.7.0
Windows 8 x64 Please provide any additional information below. I've tried all sorts of ways to escape something in order to get the output of "\b" and nothing I've tried works.
Original issue: http://code.google.com/p/dngrep/issues/detail?id=194
The text was updated successfully, but these errors were encountered: