I have been trying for hours to work out a solution for this problem. Let say there is a string
"hello Exclude1 4:32 test test Exclude2 5:23 hello 2:19 some more text 42:3 more text"
I am trying to create a C# regx which will only match 2:19 and 42:3
but ignore Exclude1 4:32 and Exclude2 5:23
i.e don’t match 4:32 or n:nn if it is preceded by Exclude1 or Exclude2.
Thanks
You can use a negative lookbehind to ignore an expression preceeded by some other expression:
This will match
##:##that is not immediately preceeded by eitherExclude1orExclude2.Demos: Regular Expression | C# Code Sample