How to Seperate URL from the mail body? Iam trying to get the body message using item.body, later trying to split the data using regex but can't get the answer...can anybody any suggestions like how to proceed. Thankyou

@maddy99 What kind of data you want to Split?

Hi @maddy99,

As you want to take out url from mail body text,
Is Match isn’t suitable activity here, because Is Match gives output in the form of boolean value (True / False). If regex expression have match, then True else False.
But if you’re expecting only this much, then you can go with Is Match.

So to take out url from text, you can use Matches activity to take out more than one match (url) it’s output of type collection of Match, but if you’re expecting only one match or Url, then you must use regex.Match method in Assign activity as shown below.

URL = System.Text.RegularExpressions.Regex.Match(item.Body.ToString,"(.*(\/\/).*\..*[^\s])").Value

URL is of type String,
as you can see the pattern in above code, there’re no anchors like ^ & $
where,
^ —> Represents start of string
$ —> Represents end of string

If your email body is —> some text abcd https://forum.uipath.com some text xyz.
and you used those anchors, then it’s not gonna work.
So, you must eliminate them whether it’s in Is Match, Matches or regex.Match.

1 Like

Hi @samir

Thank you so much for the information…I Will try it and update you if anything needed…