Remove Outlook status from string

Is there a way to dynamically remove email status from a string extracted from an attached outlook email?
For example from “LastName, First name, Online; testemail@test.com, unknown; Last2, First2, CustomStatus” to “LastName, First name; testemail@test.com; Last2, First2”?

Could yo please clarify your input and required output?

Input: LastName, First name, Online; testemail@test.com, unknown; Last2, First2, CustomStatus

Output: LastName, First name; testemail@test.com; Last2, First2

Removed: Online, unknown and CustomStatus

HI @mj.work

How about this expression

String_val.Replace("Online", string.Empty).Replace("unknown", string.Empty).Replace("CustomStatus", string.Empty)

Another Method Using Regular expression

System.Text.RegularExpressions.Regex.Replace(InputString, "\S+(?=;);|\S+$", "").tostring.Trim

Hi @mj.work

Try this

InputString="LastName, First name, Online; testemail@test.com, unknown; Last2, First2, CustomStatus"
Pattern=",[^,;]*;|,[^,;]*$"
System.Text.RegularExpressions.Regex.Replace(InputString, Pattern, ";").TrimEnd(";"c)

@mj.work

System.Text.RegularExpressions.Regex.Replace(str,“(,\sOnline)|(,\sunknown)|(,\sCustomStatus)”,“”)

String.Join(“,”,(Str.Split({",“c,”;"c},StringSplitOptions.RemoveEmptyEntries).Where(Function(a) Not {“Online”,“unknown”,“CustomStatus”}.Contains(a.Trim))))

Hi, you can use below expression:

Please check attached workflow

emailContent = “LastName, First name, Online; testemail@test.com, unknown; Last2, First2, CustomStatus”

emailContent = System.Text.RegularExpressions.Regex.Replace(emailContent, “(, \w+; [A-Za-z0-9._%±]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}, \w+; )”, "; ")

emailContent = emailContent.Replace("Placeholder; ", “”)


Email_Content.xaml (6.8 KB)

This works great. Thanks

1 Like

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