• Login
Community
  • Login

Get normal text and find all

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 3 Posters 1.8k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F
    fred339
    last edited by fred339 May 7, 2022, 4:24 PM May 7, 2022, 4:21 PM

    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:

    1. End up with text that looks like what shows in Notepad.
    2. Find all the occurrences of:
      xyz OR abc
      (in a single search)
    3. Copy the found results.

    What’s a good approach for this?

    P N 2 Replies Last reply May 7, 2022, 4:40 PM Reply Quote 0
    • P
      PeterJones @fred339
      last edited by May 7, 2022, 4:40 PM

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

      1 Reply Last reply Reply Quote 1
      • N
        Neil Schipper @fred339
        last edited by May 8, 2022, 7:14 AM

        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.

        @peterjones:

        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.

        P 1 Reply Last reply May 8, 2022, 6:11 PM Reply Quote 2
        • P
          PeterJones @Neil Schipper
          last edited by May 8, 2022, 6:11 PM

          @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:

          a8707f36-7e26-4292-9fc0-e8d3d05eca51-image.png

          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 or abc 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 of xyz or abc in the clipboard, without any of the surrounding text… If Fred actually wanted to copy any lines that contain either xyz or abc, 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

          • Please Read Before Posting
          • Template for Search/Replace Questions
          • FAQ: Where to find regular expressions (regex) documentation
          • Notepad++ Online User Manual: Searching/Regex
          1 Reply Last reply Reply Quote 1
          1 out of 4
          • First post
            1/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors