Extract String between two Special Characters

Hii, Please help ASAP, its little urgent

I have a string in this format (datatype: String).

“”,,,

Expected Result : I want this data into list
List(String) = Jack, Rome, Mile, Bow

Please help me into this.

Hi @Dummy

What is your Input String. Please specify.

Regards

“,,,”

@Dummy, can you give us a sample input?
but not this!!

“,,,”

Thank you!!!

What is your expected output @Dummy . Please provide input and output as your query is confusing.

Regards

Sorry I don’t know why it is not accepting angular brackets.

This data are enclosed in separate angular bracket .Each angular bracket is separated by comma.

Hi @Dummy

Atleast share the screenshot of your requirement by writing it in Notepad file.

Regards

Hi @Dummy ,

Could you please share dummy data ?

Regards,
Vinit Mhatre

image

Above Screen shot is input

Output: List(String) = Jack,Rome,Mile,Bow

Hi There,

Use split function.

Your_String = “,”

or

Your_String = “Jack, Rome, Mile, Bow”

I believe the 2nd one is your requirement.

For that List_1 = Your_String.split(“,”)

Hope this helps you. Please elaborate the input if you need more clarity or the exact functions to use.

Good Day,
Rama Krishna Dokina

Hi @Dummy

You can simple use Replace function for that

inputString = "<Jack>, <Rome>, <Mile>, <Bow>"

outputString = InputString.Replace("<", "").Replace(">", "").Split(","c).Select(Function(s) s.Trim()).ToList()

outputString isof DataType System.Collections.Generic.List(Of System.String)

Hope you understand!! @Dummy

Regards

Hi @Dummy ,

Hope it helps you :slight_smile:

New_List: (List)

 your_Var.Split(","c).Select(Function(s) s.Trim("<"c, ">"c)).ToList()

Output: (String)

String.Join(",",New_List)

Regards,
Vinit Mhatre

Sorry, Every approach is correct, but I wanted it more dynamic solution.
As I cannot use Split, Replace,Remove functions.
Can we achieve it through Regex.
Like anything available between angular bracket should extract.

Hi @Dummy

Try this, this should work for you.

Regards

Hi @Dummy

Try this

String.Join(", ",System.Text.RegularExpressions.Regex.Matches(Input,"(?<=\<)\w+(?=\>)"))

Cheers!!

Hii Thank you for the approach.

Let me explain you the real scenario.

Basically I wanted to extract the email Ids from outlook email.
I have extracted the email Id using emailId.To.ToString.
As there are multiple recipients present over there so string is comming out as

But I just wanted email Id to be extracted. only the content between angular brackets.

I hope you might get the point now.

hi @Dummy does this help?

(?<=<)\S*@\S*(?=>)

regards

use this regex and loop through results

Hii @Dummy,

might be this is helpful to you,

  1. Assign: inputString = “”“,”
  2. Assign: dataArray = inputString.Split(","c, StringSplitOptions.RemoveEmptyEntries)
  3. Assign: dataList = New List(Of String)(dataArray)

Thank you,
Akhil

Hii @Dummy,

I have one solution for you for extracting the email ID from your string.

  1. Use Assign Activity (or you can use multiple assign Activity) and pass your value into string (“YourValue” )

  1. Use another Assign Activity (or you can use multiple Assign Activity).

  2. Use Message Box/or Log Message Activity to verify your output

I hope this is helpful to you.
Cheers buddy.
Akhil