Doubt in Split Function

Hi, I am a UiPath Beginner. Please help me with the below query.

“Alberto smith\r\n2 scored 30\r\ngoals in 21 games” This is my Input String and I need the output as “Alberto smith scored 30” using Split Fuction.

Here Two delimiters are there one is Space and slash

Please help me to split

you want to split to

Alberto smith scored 30
and
“goals in 21 games” ?

Thanks for your reply. No I need only “Alberto Smith scored 30” from the input

can you try this

System.Text.RegularExpressions.Regex.Split(txt, "\\r\\n")(0)+ System.Text.RegularExpressions.Regex.Split(txt, "\\r\\n")(1)

test11.xaml (6.8 KB)

Hey @sharu_priya

This can be done using string manipulation.

But that doesn’t make sense without some business rule to it.

What is the business rule here so that we can build logic for all scenarios.

Hope this helps.

Thanks
#nK

Thanks much. But Why 2 is coming after smith. PFB screenshot for your reference

Thanks for your reply nithin.
It is just a small assignment given by my tutor.
Please suggest me a solution with String Manipulation

Hi @sharu_priya ,

Here is another solution →

image

image

System.Text.RegularExpressions.Regex.Replace(str_txtData,"\r?\n",chr(32))

RemoveNewLines.xaml (5.3 KB)

Kind Regards,
Ashwin A.K

Because theres a 2 in your input.

If you really want to remove the “2” you can do this

System.Text.RegularExpressions.Regex.Split(txt, "\\r\\n")(0) + System.Text.RegularExpressions.Regex.Split(txt, "\\r\\n")(1).Replace("2", "")

we are splitting by two or more characters \r\n so we have to use this function instead of the standard string.split
System.Text.RegularExpressions.Regex.Split

The String.Split function only works with single characters which is why we cant use it here
image

Sorry for the delay.

I have given now. Thanks much for your time:)

Thanks Ashwin