Beginner help with Regular Expressions and replacement

Sorry if this is in the wrong forum. Feel free to move it if it is. I'm a student learning C#. I'm having trouble with a program I'm writing. I have a rich textbox that has been accumulating string data. This data is choices the user has selected. I'd like to allow the user to remove choices. I’ve tried getting the data in the rich textbox and replacing their choice with “” but this replaces all instances of their choices. I’d like it to remove it or replace it just once. I think this can be done with regular expressions, but I don’t know how to do this. If someone could write me some sample code I’d appreciate it.



Answer this question

Beginner help with Regular Expressions and replacement

  • Nestor Dominguez

    Thanks that worked great.
  • Mild Bill

    You don't need regex for this, you can get the start index and length of the selection and just remove it by using substrings.



  • Beginner help with Regular Expressions and replacement