In my automation I have a Regex like :
System.Text.RegularExpressions.Regex.Match(EmailBody,“(?<=Role : ).+”).Value
it works perfectly well, but there are some changes in automation and I have 3 places now like “Role :”.
Is it possible to have a list of there 3 regexes or tell regex to get the 2nd or 3rd one?
Use Matches instead of Match to get all values from all the matches.
System.Text.RegularExpressions.Regex.Matches(EmailBody,"(?<=Role : ).+")
The above expression will give you IEumberable of matches.
ok, and assign to this list of IEnumerable?
Hi @wenar58700 ,
Could you provide us an Example of your Input Data ?
Is it that you have Multiple Role Values ? As you mentioned is it 3 of them only or does the Count of the Values Differ ?
.value is not a member of matches. I don’t know what to choose here.
@wenar58700 , Try using the Below :
System.Text.RegularExpressions.Regex.Matches(EmailBody,"(?<=Role : ).+")(0).Value
(0) is being used to access the first Matched Value.
You could try accessing other repeated time values by using
We do this accessing when we know the Definite number of times the
Role values are present for an Input.
I get value of type string cannot be converted to 1-dimensional array of string.
The variable I have is String
@wenar58700 , If you want to Store all the values in a
String, then you can use the below Expression :
System.Text.RegularExpressions.Regex.Matches(EmailBody,"(?<=Role : ).+").Cast(Of Match).Select(Function(x)x.value.ToString).ToArray