I have a complex string value and I want to remove the part between two words

Hi @HaticeKubraYilmaz , I’m thinking on possibly using Regex Replace to find the string between your 2 keywords, and then replacing it with a String.Empty, should look something like this:

System.Text.RegularExpressions.Regex.Replace(strTest,“(?<=DİPNOT).*(?=PASİF)”,String.Empty,System.Text.RegularExpressions.RegexOptions.Singleline)

image

Edit: If you also want the 2 keywords to be deleted, you can modify a bit the regex expression:

System.Text.RegularExpressions.Regex.Replace(strTest,“DİPNOT.*?PASİF”,String.Empty,System.Text.RegularExpressions.RegexOptions.Singleline)

image

1 Like