Splitting the characters

how to split the single string from a group of string
for example; hai how are you is stoed in rc1 variable
I want only how are you from the sentence how to do it

You can try this

It will work

Split(“hai how are you UiPath”, " ")(0)

Hi @anjani_priya

strinput="hai how are you"
output=strinput.Split(" "c)(0)

Hope it helps!!

Hi @anjani_priya

You can use the Split function for this, split with the space and take the first string.

- Assign -> Input = "hai how are you"
- Assign -> Output = Input.Split(" ").First

Hope it helps!!

In a ‘rc1’ variable the ‘hai how are you’ is stored
how to fetch only ‘how are you’ in that?

u can change the number accordingly.
Additionally,if you want to take first and last word u can follow this:strInput.Split(" “c).First and strInput.Split(” "c).last

System.Text.RegularExpression.Regex.match(“hai how are you” ,“(?<=hai\s).*”). Value.Trim

You can try this syntex for how are you


from group of words i want some words
example : hai how are you is stored in rc1
i want how are you only

Its very complicated, please simplify

Hi @anjani_priya
Try this:

rc1.Split({" "}, StringSplitOptions.None)(1) + " " + rc1.Split({" "}, StringSplitOptions.None)(2) + " " + rc1.Split({" "}, StringSplitOptions.None)(3)

Hope it hleps!!

If you need “how are you” you can try this

Input= "hai how are you”

Take assign activity

Rc1 = System.Text.RegularExpression.Regex.match(input,“(?<=hai\s).*”). Value.Trim

Note = rc1 you can keep variable type is system.string


Okay @anjani_priya

You can use remove function to remove this, we are using the split and remove function as well.

- Assign -> Input = "hai How are you"
- Assign -> Output = Input.Remove(0,Input.Split(" ").First.ToString.Length+1)

Hope you understand!!

Hi @anjani_priya

Try this

Str="hai how are you"
Arr=Str.Split({" "c}, StringSplitOptions.RemoveEmptyEntries)
String.Join("  ", Arr.Skip(1))

Hope this helps!!

Then in that case follow this regex

The expression which you dont want to include will not be in the resultant output

the date 31 aug’2023 is there in rc1 , by split the split the date then how to replace that with 31-08-2023

HI @anjani_priya

rc1= “31 aug’2023”

DateTime.ParseExact(rc1, "dd MMM’yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")


You can try this syntax it will work

DateTime.ParseExact(System.Text.RegularExpressions.Regex.Replace(rc1, "(st)", ""), "dd MMM’yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")

output : -


how to get the string from the path of the file

Can you share the filepath sample and expected out