Community
    • Login

    need help with deleting after 52nd column only if the line matches criteria.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 5 Posters 383 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.
    • Richard SkinnerR
      Richard Skinner
      last edited by Richard Skinner

      I’m at a roadblock.
      I’m trying to delete everything after http://domain/api/file.php?id=random7numbers

      My site was using self hosting videos with the mysite/tutorials/fileidnumber-tutorialcategorynames-subcategory.mp4

      Each url is setup this way…
      Video TItle
      URL to the video poster graphic
      URL to video file content (this has the random stuff at the end I need to delete off)
      Blank line
      Next video 3 lines
      blank line… etc

      I’m new to notepad expressions… not sure if I should use a set number of wild card spots for the random7numbers position or if there’s a way to just delete everything after the 52nd column in the lines that start with the url… .

      End goal is to get a python script to get the txt and make it into a m3u8 playlist for my website. I have thousands of how to videos for my photography site and the files are pulled in from a cdn with an api…

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

        Hello, @richard-skinner and All,

        Here is the road map to delete all characters after column 52, in lines beginning with the address :

        • Open your file in Notepad++

        • Open the Replace dialog ( Ctrl + H )

        • SEARCH ^(\Qhttp://domain/api/file.php?id=random7numbers\E.{8}).+

        • REPLACE \1

        • Tick the Wrap around option

        • Select the Regular expression search mode

        • Click on the Replace All button

        So, for instance, this example text :

        http://domain/api/file.php?id=random7numbers12345678oiuzerz fkp zejofi qpfk
        http://domain/api/file.php?id=random7numbers12345678This is a test
        http://domain/api/file.php?id=random7numbers12345678ABCDEFGHIJKLMNOPQRSTUVWXYZ
        

        would be changed into :

        http://domain/api/file.php?id=random7numbers12345678
        http://domain/api/file.php?id=random7numbers12345678
        http://domain/api/file.php?id=random7numbers12345678
        

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 1
        • Richard SkinnerR
          Richard Skinner
          last edited by

          @guy038 said in need help with deleting after 52nd column only if the line matches criteria.:

          SEARCH ^(\Qhttp://domain/api/file.php?id=random7numbers\E.{8}).+

          The random7numbers is just that, 7 random numeric characters… So that search criteria doesn’t bring nothing up…

          example
          http://domain/api/file.php?id=2673483/TitleOfClass/TitleOfLesson

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Richard Skinner
            last edited by

            @Richard-Skinner ,

            Oddly enough, when you misrepresent your data, the free gift of help provided by the people that volunteer our time in this forum will not match your actual data, because we aren’t mind readers.

            Follow the advice below, and you will get better help. Ignore this advice to your own detriment.

            ----

            Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as plain text using the </> toolbar button or manual Markdown syntax. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get… Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

            Richard SkinnerR 1 Reply Last reply Reply Quote 2
            • Alan KilbornA
              Alan Kilborn
              last edited by

              Two obviously conflicting requirements?:

              • need help with deleting after 52nd column only if the line matches criteria

              • delete everything after http://domain/api/file.php?id=random7numbers

              Clearly the second requirement is specifying something much less than 52 columns, thus: CONFLICT

              1 Reply Last reply Reply Quote 2
              • Richard SkinnerR
                Richard Skinner @PeterJones
                last edited by Richard Skinner

                @Alan-Kilborn

                with mydomain.net/path to the php/file.php?id=7777777 (the random ID for my files, aka 7randomnumbers) it equals 52 columns 
                
                PeterJonesP 1 Reply Last reply Reply Quote 0
                • L
                  litos81
                  last edited by

                  @Richard-Skinner here’s a slightly modified version of @guy038 solution:
                  Find what: ^(\Qhttp://domain/api/file.php?id=\E.{7}).+ and keep everything else as he said. It reads an url until the ‘?id= plus 7 random characters’ bit, and the replacement will remove anything that goes after that.

                  1 Reply Last reply Reply Quote 1
                  • PeterJonesP
                    PeterJones @Richard Skinner
                    last edited by

                    @Richard-Skinner ,

                    Rather than arguing with those who are trying to help you, why not provide better example data, for both “before” and “after” the transformation you want, that matches your description of the data, so that we have a better understanding of what you’re trying to achieve? Since your descriptions don’t match the example text, it’s rather difficult for us to come up with a regex that will work with your data. If column number is the important thing, then focus on columns in your description and example data; if the important thing is actually anything after the seven digits of ?id=7777777, then focus on that string and not column number. But insisting on 52 characters when your example data isn’t 52 characters long is … tiring.

                    Even though you haven’t shown that you understood or took my advice to heart, I’ll give you two guesses: one that assumes that the critical piece of information is 52 characters, and one that assumes that the id is the critical piece:

                    52 char

                    • FIND = (?-s)^(.{52}).*$
                      • Explanation: turn off .-matches-space, match beginning of line, match 52 characters and store in group 1, match remaining characters on line
                    • REPLACE = $1
                      • replace with contents of group 1 (so effectively deletes everything after the first 52 characters)
                    • MODE = Regular Expression

                    ID

                    • FIND = (?-s)(\?id=\d{7}).*
                      • Explanation turn off .-matches-space, match ?id= followed by 7 digits and store in group 1, match remaining characters on line
                    • REPLACE = $1
                      • replace with contents of group 1 (so effectively deletes everything after the 7-digit ID)
                    • MODE = regular expression
                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors