[Help] RegExMatch : How to escape "-" character

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
titep
Posts: 31
Joined: 14 Nov 2015, 09:01

[Help] RegExMatch : How to escape "-" character

16 Apr 2017, 00:01

My AHK CODE

Code: Select all

PosMatch := RegExMatch(string,"class=""meta-author hidden-xs""><span>")
it matches :
0 - <cite class="meta-height hidden-xs">
1 - <span class="meta-weight">
2 - <span class="meta-name">

0 is the only what I need RegExMatch match.

I figure it out that the character "-" in RegExMatch causes the problem. But I don't know how to fix after using all my knowledge and googling.

Thank you in advance
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: [Help] RegExMatch : How to escape "-" character

16 Apr 2017, 04:42

I don't think your posted code matches any of your three cases.
Try this:

Code: Select all

; case 0
    String = <cite class="meta-height hidden-xs">
    Gosub, TestCode

; case 1
    String = <span class="meta-weight">
    Gosub, TestCode

; case 2
    String = <span class="meta-name">
    Gosub, TestCode

ExitApp




TestCode:
    ; original code: DOES NOT match any
    ;PosMatch := RegExMatch(String, "class=""meta-author hidden-xs""><span>")

    ; try this instead
    PosMatch := RegExMatch(String, "class=""meta-height hidden-xs"">")

    MsgBox, %PosMatch%

Return
I hope that helps.
titep
Posts: 31
Joined: 14 Nov 2015, 09:01

Re: [Help] RegExMatch : How to escape "-" character

17 Apr 2017, 00:37

thank wolf_II

I am waiting for the answer for the whole yesterday !

Thanks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 113 guests