How to split the string data


#1

i have a string as From : xxxx@gmail.com
hello world
ramesh@gmail.com
2/18/2018.
i want to extract the data as ramesh@gmail.com, as between the < > .

ihave tried as string.split({"<"},stringsplitoptions.none)
but i am getting the data as
ramesh@gmail.com
2/18/2018.

so.pls suggest me the solution , Thanks in advance


Extracting letters from a word/string
#2

HI @lalithya14,

If you are reading the data from notepad.
you can use Read Text File Activity, it will return the String value.
after getting the value using split Environment.NewLine option spit the value to array
For loop through the array value you can get the each value.
To split the data use below code
arrvalue= strvalue.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)

use “c” after <
string.split({"<"c},stringsplitoptions.none)

Regards,
Arivu


#3

Hi arivu,
string.split({"<"c},stringsplitoptions.none) i have used in my case but its not working

i have a string as From : xxxx@gmail.com
hello world
<ramesh@gmail.com>
2/18/2018.
here i want to get only the data between < > so, i have tried
string.split({"<"c},stringsplitoptions.none) but its giving me

                                   ramesh@gmail.com>
                                   2/18/2018.   data

#4

@lalithya14, Use this , This one works

String.Split(new string() {"<",">"}, StringSplitOptions.RemoveEmptyEntries)(1)

Regards,
Dominic :slight_smile:


#5

Hi @lalithya14,
Try this code

stringVal.Split('<', '>')[1]

Regards,
Arivu


#6

thanks for your answer but i am not getting the output please help me

please find the attachments cs.xaml (6.8 KB)


#7

its not working i am getting the data as

xxxx@gmail.com
hello world

till < i am getting the data


#8

You really just needed to .Split it twice and on the second one use the (0) item, like .Split()(1).Split()(0), and use “<” in the first and “>” in the second.

You can also consider a Regex pattern to pull out the email.
System.Text.RegularExpressions.Regex.Match(text,"(?<=\<).*(?=\>)").Value

or use .Matches if there’s many email addresses in the text and it will create a list of the matches.

Regards.


Invoke code for string variable
#9

Hi @lalithya14,
Try this code

strValue.Substring( strValue.IndexOf("<")+1, strValue.IndexOf(">")-(strValue.IndexOf("<")+1))

Regards,
Arivu


#10

thanks arivu