Trim or substring

how you are passing the string can you show me :slight_smile: screenshot or your sample workflow

test_123.xaml (5.6 KB)

Please find attached sample workflow, i am using.

Request you to please copy below string and then run the script:

Forma : líquido
Color : amarillo a Amarillo dorado
Gusto : (valor) no determinado

Since, myString.Indexof(“\n”) = -1, i am not able to use Substring option in the Assign activity to extract content of Color (i,e, amarillo a Amarillo dorado)

var x = yourstrvar.IndexOf(Environment.NewLine)

@ddpadil

Environment.NewLine represents \r\n (a carriage return + line feed) whereas if she only have a line feed in her source string then she can use above i have mentioned but still try and check @prachi.yadav

Regards…!!
Aksh

1 Like

Hi Aksh,
My string is like
Name: Anjali
date(DD-MON-YY): 01-01-1900

I want to fetch Anjali and date 01-01-1900 and copy this in an excel.
Can you please suggest?

Thanks,
Anjali

Hey @anjalimishra

You can split your text file data with “:” and newline then use the array index to get your values.

String[]= str.Split({":"c,Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)

Regards…!!
Aksh

Hi ,
The data is coming from email, please check the screenshot below I am still not able to fetch the correct value.

Hey if you are not using the text file then data will be in same line? if you are getting string?
will you print your data ? by using write line? because have to modify the delimiters in split on the basis of data.

Please check the complete mail data below: kindly ignore (==============)

================================================================
Name: Anjali

Date(DD-MON-YY): 01-01-1900

Thanks and Regards,

Anjali

================================================================

So it looks like a string so replace Environment.Newline with “\n” and then give it a try. or just other way manipulate your string just with “:” delimiter then replace the character till the index of “:”.

Regards…!!
Aksh

\n is giving the same output. which function can we use for other part?

Sorry forgot it was “\n\r” carriage return as well :slight_smile: but i wanna see it on console how it is in actual because it is coming on same line? or else. running short of time. hurry :slight_smile:

I have used v_Mail_Body.Substring(v_Mail_Body.IndexOf(“:”),v_Mail_Body.IndexOf(Environment.NewLine)) but this is also not proving partial output(Name).

in short do one thing… even there is new line or not replace all witth “” so they will come in same line then split with space and “:” then access your index. String manipulation is in your hands how you can manipulate as per your needs.

Just for reference use the sample workflow and pass your string and then check how it is returning words… then use the separator as per your needs.

Split Words.xaml (6.2 KB)

Regards…!!
Aksh

Hi Aksh,
When I tried giving email data in your XAML I was able to see that the string is splitting on the basis of “:” but the same thing is not happening when data is coming from email.

Please suggest.

Thanks,

Then best thing to writeline that email data and check what is difference between them and observe.

I tried using Regex.Split(value, “\r\n”);but getting an issue “Regex is not declared”.

you have to import the namespace for this.

Regards…!!
Akshay

Hi Saurabh_Sahu,

If I used other variable instead of C, i’m getting error.What is the use of c here. Could you explain this?
data.TrimStart(""C);

It’s not a variable, it’s a specifier that the value should not be treated as String (which is the usual behaviour if you enclose something in double quotes), but Char.