Page 1 of 1

Matching data on the clipboard with RegExMatch

Posted: 17 Apr 2024, 11:23
by jarhead
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.

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

Posted: 17 Apr 2024, 16:03
by neogna2
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

Re: Matching data on the clipboard with RegExMatch

Posted: 17 Apr 2024, 16:52
by jarhead
Close enough... thanks. Clearly over thinking this one.