Regex optimize

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Rikk03
Posts: 192
Joined: 12 Oct 2020, 02:44

Regex optimize

19 Jun 2021, 14:57

Hi, Im looking for a better regex

This is what I have

<div+\s?id\s?=\s?"[^"]*"*\s*>(?:About\s)(\d.+)\sresults


All I want to do is match the number with commas inside (2,4444,2222) and return that. This works as group 1 on regex101.
User avatar
mikeyww
Posts: 26869
Joined: 09 Sep 2014, 18:38

Re: Regex optimize

19 Jun 2021, 15:08

Specifically, what is the desired output in your example?
Rikk03
Posts: 192
Joined: 12 Oct 2020, 02:44

Re: Regex optimize

19 Jun 2021, 15:23

The number within the html tag. Just the number

<div id="result-stats">About 3,440,000,000 results
User avatar
mikeyww
Posts: 26869
Joined: 09 Sep 2014, 18:38

Re: Regex optimize

19 Jun 2021, 15:30

Code: Select all

str = <div id="result-stats">About -3,440,000,000.34 results</div>
RegExMatch(str, ">.*?\K[\d,.-]+", n), n := StrReplace(n, ",")
MsgBox, 64, Result, %n%

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 296 guests