I am trying to find a way to remove all text in a string before matching in Regex. I am coding this in C #.
For example, if the string is "hello, test matching", and the template is "test", I would like the final result to be a "test comparison" (that is, delete everything before the test).
Any thoughts? Thanks!
EDIT: I probably should have been more specific in my example after reading your answers (and thanks for them). I like the lookahead method, but I simplified my example. To complicate the situation, usually the lines look like this:
"hello, allAfter conformance test"
So, if I use the "test" pattern, it will catch the first. What is my goal - to replace the entire text after the second match. That is: the result is in "test everythingAfter" .... Sorry.
source share