I have some same word in paragraph i keep the last word only

I have some same word in paragraph i keep the last word only

For example:

Amount 20.25 is proccesed due to payment and amount 20.25 is processed due to payment as per source

My output should be:
Amount 20.25 is proccesed and amount 20.25 is processed due to payment as per source

yourstring = yourstring.replace(“amount due”, “amount”)

due to payment is more than one time so i have to make it only last due to payment to have

In my paragraph there are due to payment two times i have to keep the last due to payment word alone

Hi @sruthesanju ,

Could you check the below Expression :

dataText = "Amount 20.25 is proccesed due to payment and amount 20.25 is processed due to payment as per source"

regexExp = new Regex("due to payment",RegexOptions.Multiline)

op = Regex.Replace(regexExp.Replace(dataText,"",regexExp.Matches(datatext).Count-1),"\s{2,}"," ")

Here regexExp is of the type System.Text.RegularExpressions.Regex, dataText and op are String type variables

Visuals :

Let us know if you are not able to get the required output.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.