RegExMatch() with foreign language

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
oldbrother
Posts: 275
Joined: 23 Oct 2013, 05:08

RegExMatch() with foreign language

29 Jun 2023, 19:38

I need to get -0.33 from the string below with RegExMatch. The Chinese characters make it difficult for me to get it working. Please help!

<td>每股收益:<span>-0.33</span></td>

Thank you for your help!
User avatar
Datapoint
Posts: 311
Joined: 18 Mar 2018, 17:06

Re: RegExMatch() with foreign language

29 Jun 2023, 20:08

What is the search criteria you want to use?
If you are just looking for a number, then the language of the other characters won't matter. https://regex101.com/r/r3Yzor/1
I assume you are looking for <td>每股收益 followed by the next number? https://regex101.com/r/GcGjf0/1
You would need to save your script as UTF-8 with BOM.

Code: Select all

#Requires AutoHotkey v1.1.33

data := "0a9sd<td>每股blah益:<span>-0.33</span></td>y[ufho;in`n"
. "ioaweu8hgfsdliuh<td>每股收益:<span>-0.33</span></td>oa8we9fsyhdawer-f6<td>每blah收益:<span>-0.33</span></td>sy89phio"
. "awer-f6<td>每blah收益:<span>-0.33</span></td>sy89phio"

RegExMatch(data, "<td>每股收益:.+?\K-?\d\.\d{2}", var)
MsgBox % var
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: RegExMatch() with foreign language

29 Jun 2023, 20:26

Another one:

Code: Select all

RegExMatch(data, "<td>每股收益:\h*<span>(.+?)</span>", var)
MsgBox % var1
User avatar
oldbrother
Posts: 275
Joined: 23 Oct 2013, 05:08

Re: RegExMatch() with foreign language

30 Jun 2023, 09:30

Thank you all! It works. Have a nice weekend!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Mateusz53, MrHue, mstrauss2021 and 319 guests