If statement from get attribute

I have a automation that i need some help with when it comes to expressions.
Im using a get attribute activity and then a if statement. Im looking for the date in the get attribute variable(See Attached) the variable name from the get attribute activity is “resulthref” in the attached picture the date is formatted 3/31/20. I need my if statement to say “if resullthref contains 20” any ideas how i would write this statement?


@NATHAN_MORA - You can use the below expression to get the year from your text.

StrYear = system.text.regularexpressions.regex.match(resulthref,"(?<=Date\=\d{1,2}/\d{1,2}/)\d{2}").value

Here StrYear is String variable.

In the write line, print the StrYear to check whether the value has been fetched successfully… if yes then you it in IF statement…


StrYear = resulthref.split("/"c)(2).Substring(0,2) - This will also extracts the date. Assumption is , in your string there is no “/” other than date field.

If this is not working, please provide the sample text after masking sensitive information. we can tweak the regex for you.

@NATHAN_MORA - Any luck?

Haven’t had a chance to test it out but I will keep you posted .

For the StrYear variable you provided to i use that in an Assign activity like I have attached. StrYear (String Type) = system.text.regularexpression.regex.match(resulthref,“(?<=Date=\d{1,2}/\d{1,2}/)\d{2}”).value.

I have attached a picture.

Apologize…it should be System.Text.RegularExpressions.Regex.Match. I missed the “s”…

I have corrected it now, in my post above.

Do i need to import the system.text.regularexpesssions.regex.match?

@NATHAN_MORA - only if the statement/command is not recognized, then you have to import system.text.regular.expressions as shown below…

I used the expression in an assign activity and attached the write line output. Is this correct?

@NATHAN_MORA - is the write Line inside the loop?? If yes, then its good…

Is this what you want to extract right? am I misunderstood your requirement??

I think we are close and sorry, attached is a picture of the reports page I’m using. in the invoice column you will see report numbers in blue and I’m iterating through them and using a get attribute activity. If that attribute has 20 then I need to perform another command. So we are just iterating through and clicking on the file that has 20 in the get attribute. I also attached the message box after the get attribute activity to see the structure of the attribute im retrieving. Does this help?



Yes and No. Still not able to fully get your requirement.

Based on the initial conversation, i understood that you are trying to check the value of the year from the "Message box text’ right…for which I have provided the Regex…

Yes, and then using a if statment that says “if this Found attribute contains 20 then”

Thanks for your help today, the regular expression is working, i have to figure out a few more things to get it to iterate through all the files but so far its working.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.