New Microsoft Edge Title regex to Remove trailing junk.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 12:50

Hi,

Using WinGetActiveTitle, myTitle when a webpage is displayed in the New Microsoft Edge Browser,
it shows a lot of extra junk, which may not be wanted. Try the Active Window Info utility also.

For example:
and 1 more page - Profile 1 - Microsoft​ Edge

Also the "Microsoft Edge" part is devious, Copy it to clipboard and submit that to an online character
site like: https://www.soscisurvey.de/tools/view-chars.php
and notice the
U+200B
​
\u200B
.
characters for the supposed space between Microsoft and Edge.

Also there are several variations if "and ?? more page. Profile ? ...

I want to get a regex to remove all possible junk after the actual title,
but never any part of the actual title.

Also, if I am doing something like,
if myTitle contains Google Chrome ;this works
...
if myTitle contains Microsoft Edge ;does not work
...,
how could I detect the devious "Microsoft Edge" there?

Thanks
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 13:05

Code: Select all

myTitle := "AutoHotkey - Personal - Microsoft​ Edge" ; copied directly from actual window
RegExMatch(myTitle, ".*(?= - Microsoft.+Edge)", modTitle)
MsgBox, % modTitle
or:

Code: Select all

myTitle := "AutoHotkey - Personal - Microsoft​ Edge"
modTitle := RegExReplace(myTitle, " - Microsoft.+Edge")
MsgBox, % modTitle
Probably would want to remove the "Personal" part too, but just demonstrating how to handle the stuff in between "Microsoft" and "Edge".
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 13:22

Thanks boiler,

Great start. I still get the
and 1 more page - Profile 1
or
and 5 more pages - Profile 1
or
and 2 more pages - Profile 1
So you have removed the" - Microsoft Edge" part.

Also, I still need the "contains" replacement.

Edit:
Did not see the "or" second part. I don't know if "Personal" is a Microsoft thing.
I an using W7 New Microsoft Edge .
How many variations does New Microsoft Edge have?
I would want to keep the original actual title, and remove the Microsoft stuff,
if possible.
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 13:46

might need

and /d more pages .*
and have a [|] to include if just "Personal" is a New Edge thing.?

How to use the regexmatch for the contains thing?
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 14:09

You don’t use “contains” with this approach. This is better. Did you run it? Both versions remove the MS Edge part and gives you the rest. If you need to know if it found the MS Edge part, that can be done with the RegEx approach (without contains).
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 14:25

Hi boiler,

Sure I ran them both, I said Great Start up a bit.

No contains of course. Another approach.
If myTitle and the regex how?

Also, are you saying that your New Microsoft Edge only has "Personal" in the Title?
Mine has all the other stuff. Can you show a regex incorporating both possibilities
if so. Not the old Edge. https://emailtomail.org/Help/WhatsNew.html

I would want to remove the "Personal" if that is there, also.

Thanks
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 14:36

Below is how you can have it remove the "Personal" or "Profile 1" stuff. I don't understand if you're saying the "and 1 more page" is part of the junk it adds as well.

Code: Select all

myTitle := "AutoHotkey - Profile 1 - Microsoft​ Edge"
modTitle := RegExReplace(myTitle, " - (Personal|Profile 1) - Microsoft.+Edge")
MsgBox, % modTitle
Here's how you can do the check to see if it contains "Microsoft Edge" (including the weird space character), i.e., the equivalent of as "if ... contains":

Code: Select all

if RegExMatch(myTitle, "Microsoft.+Edge")
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 15:28

Yes. For my New Microsoft Edge on W7, I get things like:

and 1 more page - Profile 1 - Microsoft​ Edge
and 5 more pages - Profile 1 - Microsoft​ Edge

added on to the actual Title.
I swear.
What I don't get is how you are getting Personal.*Microsoft.*
I never get Personal. What Edge & what Windows are you using to get that Personal?

So I will use 2 Regexes if you think OK?

RegExmatch(myTitle, ".*(?= and.\d+.more.page.*)", myTitle)
RegExmatch(myTitle, ".*(?= Personal.*Microsoft.+Edge)", myTitle)

except that the first one returns nothing for Personal, so the second one does also.
while the first one works alone for my "more page.*" Title format.

Your
modTitle := RegExReplace(myTitle, " - (Personal|Profile 1) - Microsoft.+Edge")
is so different from your other one, and ignores the "and 1 more page.*" part anyway.

Your
if RegExMatch(myTitle, "Microsoft.+Edge")
works GREAT! Thanks a lot.
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 16:21

I am using Edge Version 86.0.622.51 (Official build) (64-bit). Windows 10 Pro, Version 1909, OS build 18363.1139.



Instead of using 2 RegExex, just use one that allows for either like this:

Code: Select all

myTitle := "AutoHotkey - and 1 more page - Microsoft​ Edge"
modTitle := RegExReplace(myTitle, " - (and \d+ more pages?|Profile 1) - Microsoft.+Edge")
MsgBox, % modTitle
(note the ? allows for the s on the end of pages to be optional -- i.e., match if it is there or not)
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 17:47

This worked for both. Thanks a lot.

I actually use LinkDesc instead of myTitle which I used for edification.

RegExmatch(LinkDesc, ".*(?= and.\d+.more.page.*)", myL)
if !myL
RegExmatch(LinkDesc, ".*(?= - Personal.*Microsoft.+Edge)", LinkDesc)
else
LinkDesc = %myL%
myL =

Glad I got you, as I had no knowledge of the Old Edge on W10
Yes boiler, I would want to remove the - Personal .* ...
I guess you would not want to install the New Edge with what you have.
I do recommend the New Edge as it loads very quickly, and does a great job
Translating, and it Speaks nicely. MS finally got one right. IMHO
It does mess up Tooltips sometimes, and does not turn them on by default,
which is why I give it a special page in my Help file.
It also crashes if you try to download .exe files, so I use .txt and rename.

Thanks
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

24 Oct 2020, 19:04

I didn’t even realize it hasn’t updated it to the latest version. I wonder why. I might download it and check it out.
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

26 Oct 2020, 18:27

Hi boiler,

I read many do switch from the old Edge to the New Edge. Do checkout my Help page
which has details to turn on ToolTips etc. The Translating and Speaking is cool. IMHO.
It really does load much quicker than Chrome. Another program (ahk) I'm giving away
for our Covid-19 program, lets you switch between IE, New Edge, Firefox and Chrome
with 1 key combo.
http://800covid2020.org/Help/WhatsNew.html

If you get it running, please look at the Title (of both hopefully), and see if a single regex
could handle both Title variations. Keep in mind that New Edge have several varations
of title. It may be that my 2 regex method is best to handle either one, although I like
singles like you tried the best.

If anyone else out there knows of other Edge Title variations, please pitch in here.

Thanks,
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

26 Oct 2020, 18:57

I thought what I posted was already working with both title variations.
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

27 Oct 2020, 09:48

You wrote:
myTitle := "AutoHotkey - and 1 more page - Microsoft​ Edge"
modTitle := RegExReplace(myTitle, " - (and \d+ more pages?|Profile 1) - Microsoft.+Edge")
MsgBox, % modTitle
I do not have your Edge, so I can't know for sure, but "Profile 1" seems different than "Personal"
you mentioned. Also I want to remove the entire extra stuff, not just the -Microsoft Edge,
but also the - and {1] more page - Profile [1] also, which your does not.

Does mine (2 regexes) remove the Personal.* from your Edge.?
You probable won't be able to really test without actually having the NEW Edge installed
somewhere.

Thanks
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

27 Oct 2020, 09:56

What I posted does remove “and 1 more page” or “and 2 more pages” and so on, but not tested on the real thing, only versions of titles I typed up. Maybe they are also hiding a weird character like “Microsoft Edge” part does. Can you post some full unedited titles that are copied directly from the Window Spy tool? Then I can modify the RegEx to work.
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

27 Oct 2020, 10:32

Code: Select all

Box Editor - 800covid2020.org - emailtomail.com and 1 more page - Profile 1 - Microsoft? Edge
ahk_class Chrome_WidgetWin_1

Editing US10014 - and 2 more pages - Profile 1 - Microsoft? Edge
ahk_class Chrome_WidgetWin_1
Again, Does mine (2 regexes) remove the Personal.* from your Edge.?
What are the variations on your Edge?
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

27 Oct 2020, 11:09

Sorry, I thought your title had either the "and 1 more page" or the "Profile 1". This gets rid of both whether only the "Profile 1" part is there (I assume it's always there) or both are there.

Code: Select all

MyTitle := "Box Editor - 800covid2020.org - emailtomail.com and 1 more page - Profile 1 - Microsoft? Edge"
modTitle := RegExReplace(myTitle, "( and \d+ more pages?)? - Profile 1 - Microsoft.+Edge")
MsgBox, % modTitle

Yes, your RegEx statements work with mine. I see now as I browse more pages with it, I also get the part about more pages. It always shows "Personal" on mine.

By the way, it doesn't appear that mine is an older version. It looks to be what is shown online to be the very latest: Version 86.0.622.51
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

27 Oct 2020, 12:42

Does your new Edge do Translating and Speaking ?
User avatar
boiler
Posts: 16989
Joined: 21 Dec 2014, 02:44

Re: New Microsoft Edge Title regex to Remove trailing junk.

27 Oct 2020, 13:52

Yes, it does everything the latest version does because it's the latest version.
Visioneer
Posts: 140
Joined: 07 Oct 2013, 18:51

Re: New Microsoft Edge Title regex to Remove trailing junk.

01 Nov 2020, 10:14

Thanks boiler.

I guess the Title is different just based of the Windows version.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], KolaBorat and 84 guests