How to replace text without losing other formatting below it

Viewed 86

I need to delete all text in html of body letter before one word from set of values ("Уважаемый", "Уважаемая", "Уважаемые"). I try to do like this:

LetterBody.Replace(Regex.Split(LetterBody, "(?=Уважаемый)|(?=Уважаемая)|(?=Уважаемые)")(0), "")

but using this method I lose almost all the formatting in the body of the email.

I programming in UiPath Studio using vb.net

1 Answers

Try using Substring and IndexOf.

Would look something like:

var myParameter = "Уважаемый";    
var stuffINeed = LetterBody.Substring(LetterBody.IndexOf(myParameter) + myParameter.Length);

You could do this with the Invoke Code method or just use an Assign and replace the myParameter variable with the context you require. The above will remove everything before the myParameter keyword you choose.

If you want to remove everything after it then you would add after the above:

var endResult = stuffINeed.Substring(0, stuffINeed.IndexOf(myParameter))
Related