Help replacing part of a string

Hello! I am trying to replace parts of a string, but I am not proficient enough in string manipulation or Regex to do so gracefully.

Here is the string input for my process:

Left Operand1:criteria;LeftOperand2:criteria;LeftOperand3:critera%MiddleOperand1:criteria;MiddleOperand2:criteria;MiddleOperand3:criteria%RightOperand1:criteria;RightOperand2:criteria;RightOperand3:criteria

You’ll observe how there are three each of the ‘left operand’, ‘middle operand’, and ‘right operand’, however, there could be any number of those.

I need to remove any instance of those left/middle/right operand words and the colon that comes after them, leaving only the ‘criteria’, semi-colons, and percent signs.

Thanks in advance for any help!

See if the following expression helps you:
Regex.Replace(varMyText, "LeftOperand\d*:|RightOperand\d*:|MiddleOperand\d*:", "")


That worked perfectly - thank you so much!

1 Like

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