Get normal text and find all
-
I have some .rtf log files that appear nicely in Notepad.
But, in Notepad++ they show control characters or strings like \par at the beginning of lines.What I need to do is this:
- End up with text that looks like what shows in Notepad.
- Find all the occurrences of:
xyz OR abc
(in a single search) - Copy the found results.
What’s a good approach for this?
-
@fred339 ,
RTF is a text-based format, but it uses the backslash for doing its formatting. Any text editor, whether Notepad++ or MS notepad.exe, will show you the underlying codes in an RTF, because that is the contents of the file. (Just like they show the HTML code if you open an HTML file.)
If you want just the rendered text, then you are thinking of a word processor, not a text editor. Something like MS WordPad that comes with your OS, or a freeware word processor like LibreOffice Writer, will show you the rendered text without the underlying codes.
In Notepad++, you could just delete all the backslash sequences before doing text manipulation, but then it ceases to be an RTF file.
-
I’m confused about this exchange.
@fred339 said:
.rtf log files that appear nicely in Notepad
But, in Notepad++ they show control characters or strings like \par at the beginning of lines.Notepad++ or MS notepad.exe, will show you the underlying codes in an RTF
It should be understood why a file would look so different in the two programs. Perhaps Fred could provide screenshots (see FAQ).
Otherwise,
Find all the occurrences of: xyz OR abc (in a single search)
is easy: Find All, with mode regular expression
xyz|abc
Also, Fred, if you want a full resolution, you need to reduce misunderstandings, and showing (1) sample chunk of text to search, and, (2) the corresponding result format, would go a long way to achieve this. See FAQ for how to make text you paste into a comment appear…
in a literal text box like this
which protects it from being altered by this forum’s software.
-
@neil-schipper said in Get normal text and find all:
It should be understood why a file would look so different in the two programs. Perhaps Fred could provide screenshots (see FAQ)
Unless Fred comes back, we might never know. My experiments show that the situation will not arise: looking at a valid RTF in a word processor like Word Pad, you will see a pretty, word-processed document; but if you look at it in a text editor, whether it is MS Notepad or our Notepad++, it will show the underlying code, as seen below:
So I cannot replicate the initial situation that Fred described. My first guess is that Fred was mistaken, and was actually looking at the RTF in WordPad or some other word processor, not in notepad.exe like was originally stated. But if there is proof to the contrary, I would be curious to see enough evidence to be able to replicate what I believe is an impossible situation.
That said, Neil’s regular expression (regex) solution is the right way of doing the search in Notepad++. But it won’t “copy the results.” If Fred needs the “copy” as well, then use the Mark dialog with the same regular expression; once
xyz
orabc
are marked, then use Search > Copy Styled Text > Find Mark Style (or Find Style (Marked) in slightly older versions of Notepad++) will place all the text that was highlighted in the Mark action into the clipboard. But that seems a bit silly, because it will just end up with N copies ofxyz
orabc
in the clipboard, without any of the surrounding text… If Fred actually wanted to copy any lines that contain eitherxyz
orabc
, then the regex would have to be modified to select the whole line:(?-s)^.*(abc|xyz).*$
. So, as you said, unless Fred does a much better job of describing what is actually wanted, Fred will likely be disappointed with the results of our guessed solutions.----
Some bonus info for @fred339:
Useful References