• Login
Community
  • Login

Regex: How do I search for My_String [any characters] [quotation mark] ?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
18 Posts 4 Posters 3.7k 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.
  • A
    Alan Kilborn @PeterJones
    last edited by Nov 15, 2022, 9:58 PM

    @PeterJones said in Regex: How do I search for My_String [any characters] [quotation mark] ?:

    I think @Alan-Kilborn has a script he published a few months back that does a “space insensitive” search

    HERE is the requested script (only 3 weeks old, not months).

    I 1 Reply Last reply Nov 16, 2022, 4:40 PM Reply Quote 3
    • I
      IanSunlun @Alan Kilborn
      last edited by IanSunlun Nov 16, 2022, 4:41 PM Nov 16, 2022, 4:40 PM

      @Alan-Kilborn and @PeterJones
      thanks, I installed that and it appears its working for me.

      To add a little complication into the mix, I am searching in .mhtml files.
      These files have a habit of putting an ‘=’ (equals sign) sign at the end of many lines. Is there anything I can add to the search term to include the possibility of finding an equals sign in the midst of a search phrase ?

      So, I might get: MyStringabcdef=
      ghijklm12345

      A 1 Reply Last reply Nov 16, 2022, 6:24 PM Reply Quote 0
      • A
        Alan Kilborn @IanSunlun
        last edited by Nov 16, 2022, 6:24 PM

        @IanSunlun

        Is there anything I can add to the search term to include the possibility of finding an equals sign in the midst of a search phrase ?

        I suppose you could change the script part where it uses r'\h*' to be r'[\h=]* instead…

        I 1 Reply Last reply Nov 16, 2022, 6:53 PM Reply Quote 1
        • I
          IanSunlun @Alan Kilborn
          last edited by IanSunlun Nov 16, 2022, 6:54 PM Nov 16, 2022, 6:53 PM

          @Alan-Kilborn I’ll give that a try.
          What happens if I want to keep some of what I find in the search string in the replacement string?

          E.g. lets say I find:
          MyStringAbcd=
          efg12345xyz

          And I want to replace it with:
          MyNewStringAbcdefg99999xyz

          Is it possible to store in, for example, ${1} the Abcdefg ?

          A N 2 Replies Last reply Nov 16, 2022, 7:03 PM Reply Quote 0
          • A
            Alan Kilborn @IanSunlun
            last edited by Alan Kilborn Nov 16, 2022, 7:03 PM Nov 16, 2022, 7:03 PM

            @IanSunlun said in Regex: How do I search for My_String [any characters] [quotation mark] ?:

            What happens if I want to keep some of what I find in the search string in the replacement string?

            I guess that could get tricky.
            I don’t have all the answers. :-(
            I suppose it is something you have to experiment with, see if you can make it do what you want it to.

            1 Reply Last reply Reply Quote 1
            • N
              Neil Schipper @IanSunlun
              last edited by Nov 16, 2022, 8:16 PM

              @IanSunlun If you’re confident a trailing equal sign =\R won’t ever appear in a context where you want to preserve it, then do a pass where you just blow them all away (before the pass where you do other text replacement).

              I 1 Reply Last reply Nov 16, 2022, 8:21 PM Reply Quote 1
              • I
                IanSunlun @Neil Schipper
                last edited by Nov 16, 2022, 8:21 PM

                @Neil-Schipper thanks, yes, I just did that a few mins ago.
                I was concerned that .mhtml file was limiting line length to 76 chars for a reason.
                I blew the =\r\n away for all the files, and they load up in the browser OK, so hopefully the = was not critical.

                P 1 Reply Last reply Nov 16, 2022, 8:33 PM Reply Quote 0
                • P
                  PeterJones @IanSunlun
                  last edited by PeterJones Nov 16, 2022, 8:35 PM Nov 16, 2022, 8:33 PM

                  @IanSunlun ,

                  Wait, 72 character line length and = ending a line. I think your .mhtml might be using Quoted Printable . The = at the end of a line does have a meaning in QP.

                  You really need to learn the file types you are editing before you start hacking around at things willy-nilly. Good luck getting that .mhtml to work right after all your edits.

                  I 1 Reply Last reply Nov 16, 2022, 8:43 PM Reply Quote 1
                  • I
                    IanSunlun @PeterJones
                    last edited by IanSunlun Nov 16, 2022, 8:44 PM Nov 16, 2022, 8:43 PM

                    @PeterJones
                    I’m trying to download my website for offline viewing. I downloaded .mhtml files. There seemed to be no other option for .mhtml saving - the default seems to have been this Quoted Printable format you mentioned.

                    I took out all the =\r\n episodes in all the .mhtml files and loaded them back into my browser.
                    Nothing seems to have changed. Its browsing and viewing them all fine. Now my other search and replace tasks will be easier.
                    All I am needing is offline browsing.

                    P 1 Reply Last reply Nov 16, 2022, 8:46 PM Reply Quote 0
                    • P
                      PeterJones @IanSunlun
                      last edited by Nov 16, 2022, 8:46 PM

                      @IanSunlun ,

                      I just checked; yes, saving a webpage as .mhtml from a major browser will use quoted-printable.

                      If you really want to correctly do this:
                      b51566b2-3818-44da-ae91-9e391acbcc46-image.png

                      1. Select one part (the HTML part of the multipart, for example)
                        7ba2d2b6-b23b-4324-9aa4-9dffc06a5b90-image.png
                      2. Plugins > MIME Tools > Quoted Printable Decode
                        38b62dc5-c946-4a92-a1d1-2a8f1a709ea0-image.png
                      3. Do your search/replace
                      4. Select all that text again
                      5. Plugins > MIME Tools > Quoted Printable Encode

                      You will find it’s much easier to work with that way.

                      I 1 Reply Last reply Nov 16, 2022, 8:49 PM Reply Quote 1
                      • I
                        IanSunlun @PeterJones
                        last edited by Nov 16, 2022, 8:49 PM

                        @PeterJones Ah, thats good to know, thanks !

                        1 Reply Last reply Reply Quote 0
                        17 out of 18
                        • First post
                          17/18
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors