Multiple Assign With Try Catch

Hello friends!

I have a question about Multiple Assign with Try Catch activity.

I have the following problem:

I have a text document from which I am reading various data using RegEx.

Now I want to be able to read these read values with a match activity in UiPath. To format the read value to a string I have always done the following:

(insert screenshot)

Is it possible to format several matches at once to strings with a Try Catch activity and a Multiple Assign activity and if a match was not found, to intercept this by the Catch function?

Example:

3x Regex matches, 2x of them are found:

Try Catch:

Try Function:
Multiple Assign:

Str_Match1 = Mat_Match1(0).groups(1).value
Str_Match2 = Mat_Match2(0).groups(1).value
Str_Match3 = Mat_Match3(0).groups(1).value

Catch:

If Str_Match1 = No Match | Str_Match 1 = “No match found”.

If Str_Match2 = No Match | Str_Match2 = “No Match found”.

etc.

Hi,

I don’t think it’s very good idea to recovering them in Catch block, because if there is exception in second expression, we need to evaluate 3rd expression after that and it seems complicated.

So,I think it’s better to evaluate each expression in MultiAssign as the following, for example.

Str_Match1 = if(Mat_Match1.Count>0 AndAlso Mat_Match1(0).Groups.Count>1,Mat_Match1(0).Groups(1).Value,"No match found")
Str_Match2 = if(Mat_Match2.Count>0 AndAlso Mat_Match2(0).Groups.Count>1,Mat_Match2(0).Groups(1).Value,"No match found")
Str_Match3 = if(Mat_Match3.Count>0 AndAlso Mat_Match3(0).Groups.Count>1,Mat_Match3(0).Groups(1).Value,"No match found")

Regards,