How to save a regex value as a string variable?

Hey!

I’m able to extract specific words from a mail body by using regex and match activity.
Now I want to work with those extracted words, but I’m struggling with the regex value type.
I was trying to use that extracted word in google search function, but its not working. I’m getting “System.Linq.Enumerable+d__97`1” as a string.

How can I store that regex value in a string variable?

Why is this readable? :

1 Like

Hi @Ilga_Muller

Have you tried using for each item

Thanks
Ashwin S

1 Like

@AshwinS2 thank you for your help!
What do you mean by that? ForEach and Assign in the body? Like newvariable = oldvariable.ToString? … I did, and its not working.

Hi @Ilga_Muller

Use For each item in Match values

and then print the values within for each item

Thanks
Ashwin S

@Ilga_Muller

If you had only characters in your mailbody you can use

System.Text.RegularExpressions.Regex.Replace(YOURSTRING,"[a-zA-Z]","")

This above is the quick and dirty part, you can also use this plattform to build your own pattern

This is realy helpful for string manipulations

Fine
hope these sequence would help you on this
–once after using MATCHES activity it will give us output with a variable of type
System.Collections.Generic.Ienumerable(System.Text.RegularExpressions.Regex.Match)
–now use a FOR EACH activity where pass this output variable from MATCHES activity and change the type argument as System.Text.RegularExpressions.Regex.Match
–inside the loop use a Message box like this
item.ToString which will show us each match found n the matches activity
or if we want to save that match found in a variable use a assign activity like this
str_output = item.ToString
where str_output is a variable of type string
but for each iteration the value of the variable str_output will change

Cheers @Ilga_Muller

1 Like

@ruh_hastasi77 thank you, the extracted word is correct, I already checked it.

@AshwinS2 I can print that extracted word with msg Box and using “String.Join (” ", datum) " but I cant store that value as a string, because I dont know how. Or am I missunderstanding you?

Thank you @Palaniyappan I’m trying this out

1 Like

Hope I will understand it right

  1. Take an assign acitivity
  2. On the left side you declare one variable with (Strg + K)
  3. On the right you paste the line in the Message Box

→ And then you have your variable :slight_smile:

1 Like

@Palaniyappan I still cant find the type.

This is my import list:

Those are the only combinations I can use with RegularExpressions:

What can I do about this?

@ruh_hastasi77 thank you very much, its working fine by printing it in a msg box. I’m using String.Join( " ", datum) in the msg box and it shows me the extracted word. I just want to use that word for more functions. Like googling that word. But by storing it as a string variable.

1 Like

AssignVariable.xaml (7.6 KB)

@Ilga_Muller

we can choose this as a first type
image

Cheers @Ilga_Muller

@Palaniyappan there is not such a type. I really dont know how I can get that type into uipath studios.

@ruh_hastasi77 thanks! Thats an interesting way. I’m trying this out.

1 Like

@Ilga_Muller

System.Text.RegularExpressions.Regex = String

You dont have to change the datatype of the variable.

So Ilga frohes Schaffen! :slight_smile:

aah we can directly choose this type
image

Cheers @Ilga_Muller

here you go with an example for matches activity with the datatype chosen
mota.zip (9.8 KB)

Cheers @Ilga_Muller

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