Matching data on the clipboard with RegExMatch Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
jarhead
Posts: 151
Joined: 09 Sep 2020, 12:43

Matching data on the clipboard with RegExMatch

Post by jarhead » 17 Apr 2024, 11:23

I'm using RegExMatch on the clipboard to assign variables to found data like so...

Code: Select all

RegExMatch(A_Clipboard, 's)<d:Last_x0020_Name.*?>(.*?)</d:Last_x0020_Name>', &LastName)
RegExMatch(A_Clipboard, 's)<d:First_x0020_Name.*?>(.*?)</d:First_x0020_Name>', &FirstName)
I'm trying to match a value only if it is provided. When the value is blank, the clipboard data returned is <d:Case_x0020__x0023_ m:null="true" />. When the value exists, the clipboard data returned is <d:Case_x0020__x0023_>123456</d:Case_x0020__x0023_>. So if it exists, I want to grab 123456 and assign it to a variable and if it does not exist, do nothing.

I know if the value always existed, I could use something like RegExMatch(A_Clipboard, 's)<d:Case_x0020__x0023_>(.*?)</d:Case_x0020__x0023_>', &CaseNum).

Any assistance is appreciated.

neogna2
Posts: 598
Joined: 15 Sep 2016, 15:44

Re: Matching data on the clipboard with RegExMatch  Topic is solved

Post by neogna2 » 17 Apr 2024, 16:03

I may be missing something but it sounds like you could just do this?

Code: Select all

if RegExMatch(A_Clipboard, 's)<d:Case_x0020__x0023_>(.+?)</d:Case_x0020__x0023_>', &CaseNum)
    return CaseNum
else
    ; do somethings else

jarhead
Posts: 151
Joined: 09 Sep 2020, 12:43

Re: Matching data on the clipboard with RegExMatch

Post by jarhead » 17 Apr 2024, 16:52

Close enough... thanks. Clearly over thinking this one.

Post Reply

Return to “Ask for Help (v2)”