Tuesday, May 22, 2012

C# Regex - Split and Keep Splitter

Related:
http://stackoverflow.com/a/2910549/194031



I have a string like:



"abc defgh <!inc(C:\my files\abc.txt)!>kdi kdkd<!inc(C:\my files\abc.txt)!>"


and I want to get:



["abc defgh ", "C:\my files\abc.txt", "kdi kdkd", "C:\my files\abc.txt"]


Also, I don't want



"abc <!inc(C:\my files\abc.txt adf" (missing end bracket) 


to get split.



Based on the related question and other similar answers, I need to use look aheads, but I can't figure out how to use them while accomplishing removing the tags and not splitting if part of the tags are missing.





No comments:

Post a Comment