How to replace all duplicate substrings one by one with diffrent -2 specified words in a string

Dear All,
I want to replace a string like below example
Example : input string is : Hi Uipath Hello Uipath Hey Uipath bye uipath. i want output like : Hi 1 Hello 2 Hey 3 bye 4.
I will be very thank full if some suggest me.

Split string in Array using uipath as seperator
Then you have 4 parts
Next loop with counter

unfortunately not done with an oneliner, but is working and ignores the cases:


with: Regex.Matches(strText,"UiPath",RegexOptions.IgnoreCase) the relevant parts are found
with: New Regex(item.Value).Replace(strText,(idx + 1).toString,1) the found text is replaced by counter No

Find demo XAML here:
ReplaceOccurenceStringWithCounter.xaml (6.1 KB)


Thank you so much. It worked @ppr