Regex: How do I search for My_String [any characters] [quotation mark] ?
-
@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 -
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 ber'[\h=]*
instead… -
@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=
efg12345xyzAnd I want to replace it with:
MyNewStringAbcdefg99999xyzIs it possible to store in, for example, ${1} the Abcdefg ?
-
@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. -
@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). -
@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. -
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.
-
@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. -
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:
- Select one part (the HTML part of the multipart, for example)
- Plugins > MIME Tools > Quoted Printable Decode
- Do your search/replace
- Select all that text again
- Plugins > MIME Tools > Quoted Printable Encode
You will find it’s much easier to work with that way.
- Select one part (the HTML part of the multipart, for example)
-
@PeterJones Ah, thats good to know, thanks !