Extracting info from Subject line in Gmail

Hello,
I am trying extract info from the subject line in Gmail inbox. The info I need to extract will always be in parentheses and there might be multiple numbers separated by commas. So for ex: if the subject is (123456), (175967), (123123) it would extract 123456, 175967 and 123123

@Peter.k

You can use a regex “Matches” activity with the pattern (\d+)

1 Like

It would be sufficient to just do like:
ArrayNumbers = “(123456), (175967), (123123)”.Replace("(","").Replace(")","").Replace(" “,”").Split(","c)

1 Like

So in that case
Is str_input = “(123456), (175967), (123123)”

Then the expression be like this
str_output = str_input.ToString.Replace(“(“,””).Replace(“)”,””).ToString

Or
**If the subject has few more words apart from those **numbers and brackets and if we want to get those numbers alone then use MATCHES activity and mention the input as str_input and expression as “\W\d+\W”
And get the output with a variable of type match collection

—now use a FOR EACH activity and pass the above obtained variable as input and change the type argument as system.text.regularexpressions.regex.match and inside the loop use a assign activity like this
str_output = str_output + item.ToString + “,”
Next to this for each loop use a assign activity like this
str_output = str_output.TrimEnd(“,”)

Cheers @Peter.k

1 Like

Thank you all for your help, I will try these and see if I can get it to work. Much appreciated!!

2 Likes

Cheers @Peter.k

1 Like

Quick follow up. I was able to extract them correctly but now I want to split them. So for example, I’ve extracted 123456, 167890, 190567 and I want it to first take 123456 and enter it in our software, then take 167890 and do the same etc. What’s the best way to do that?

the solution i gave you does that…

1 Like

sorry you’re right, will try that now. Thanks again!

1 Like