How to replace the first occurrence of a character/string in a string

How to replace the first occurrence of a character/string in a string.
Input string is : “Hello Testing Hello String”.

Expected output : “Testing hello String”.

Thanks in advance.

Hi @MariaJosephina
Let us say that the input is stored in strInput
Use this code to get the expected output (you can use it in assign activity)
Strings.Replace(strInput, Split(strInput, " ")(0).ToString, "", , 1).ToString

Let me know if this works on your end :slight_smile:
Thanks and regards :slight_smile:

2 Likes

Main.xaml (7.7 KB)

I used split to split the sentence into all words (you might need better logic to handle other symbols. For this example I am assuming the first word will be followed by a " " and not a “.” or “,” ect…

Then got the length of the first word and used that to then apply the .Remove to the variable.

p.s. you can ignore the notes on the example they where from another answer and do not belong in that code snippet. Sorry forgot to delete them.

1 Like

Do we have any predefined method to this?