Community
    • Login

    Remove all but specific phrase/line containing changing value.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    10 Posts 3 Posters 647 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.
    • jrdn bautistaJ
      jrdn bautista
      last edited by

      Hi, I am trying to find all the database index values from a websites source code and delete all other text/code in the document so I am only left with the values.


      Here is the data I currently have (“before” data):
      [wall of code]
      data-index="1034823\
      [wall of code]
      data-index="1031769\
      [wall of code]
      data-index="1030975\
      [wall of code]
      data-index="1028228\

      Here is how I would like that data to look (“after” data):
      1034823

      1031769

      1030975

      1028228


      I am kind of new to notepad++ and I couldn’t get my head to wrap around this one. I would appreciate the help!

      Alan KilbornA jrdn bautistaJ 3 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @jrdn bautista
        last edited by

        @jrdn-bautista:

        Try:

        Find: (?s).*?data-index="(\d+)\\
        Replace: ${1}\r\n\r\n
        Search mode: Regular expression

        Have your caret at top-of-file and press the Replace All button.

        1 Reply Last reply Reply Quote 2
        • jrdn bautistaJ
          jrdn bautista @jrdn bautista
          last edited by

          Hi, i tried this but instead of giving just the values it deleted all of the text. Could this be because all of the code is on a single line? The code only appears to be in a single line in Notepad++, not other text editors.

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by guy038

            Hello, @jrdn-bautista,

            When you start a new post, preferably click on the < / > button, on top of the posting window and replace the selected code_text zone with your present text. this will encapsulate all your text in a grey box which prevents the posting engine from possibly altering the text as it tries to format the post !

            Best Regards,

            guy038

            1 Reply Last reply Reply Quote 1
            • Alan KilbornA
              Alan Kilborn @jrdn bautista
              last edited by Alan Kilborn

              @jrdn-bautista said in Remove all but specific phrase/line containing changing value.:

              Hi, i tried this but instead of giving just the values it deleted all of the text. Could this be because all of the code is on a single line?

              If I put all of your “before” text on a single line, what I provided still works just fine, for me.

              Suggest you follow the FAQ for posting questions such as yours, in order to adequately convey all circumstances of your problem.

              1 Reply Last reply Reply Quote 0
              • jrdn bautistaJ
                jrdn bautista @jrdn bautista
                last edited by

                Here is the raw code if anyone is willing to take a look, would really appreciate it:

                pastebin com/JkEyygEV

                1 Reply Last reply Reply Quote 0
                • guy038G
                  guy038
                  last edited by guy038

                  Hi, @jrdn-bautista, @alan-kilborn and All,

                  You should have posted your text like that :

                  [wall of code]
                  data-index=\"1034823\"
                  [wall of code]
                  data-index=\"1031769\"
                  [wall of code]
                  data-index=\"1030975\"
                  [wall of code]
                  data-index=\"1028228\"
                  

                  Thus, :

                  • Move on top of your file

                  • Open the Replace dialog ( Ctrl + H )

                  The search regex S/R becomes :

                  • SEARCH (?s-i).*?data-index=\\"(\d+)\\"

                  • REPLACE ${1}\r\n\r\n

                  • Search mode = Regular expression

                  • Click on the Replace All button

                  Here you are !

                  BR

                  guy038

                  jrdn bautistaJ 1 Reply Last reply Reply Quote 4
                  • jrdn bautistaJ
                    jrdn bautista @guy038
                    last edited by

                    This worked! Sorry for the mistype, I just pasted directly from the code and I didn’t know what to edit to make it work correctly. Thank you!!

                    Alan KilbornA 1 Reply Last reply Reply Quote 1
                    • Alan KilbornA
                      Alan Kilborn @jrdn bautista
                      last edited by

                      @jrdn-bautista said in Remove all but specific phrase/line containing changing value.:

                      I just pasted directly from the code and I didn’t know what to edit to make it work correctly

                      This is why we have that FAQ entry.

                      jrdn bautistaJ 1 Reply Last reply Reply Quote 0
                      • jrdn bautistaJ
                        jrdn bautista @Alan Kilborn
                        last edited by

                        This post is deleted!
                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors