C# Regex Match any text between tags including new lines

不羁的心 提交于 2019-12-10 16:37:54

问题


Here is my regex:

\[\[START\]\]\[\[OK\]\](.*?)\[\[END\]\]

I want to get any text contained in [[START]][[OK]] and [[END]].

However when my text contains some \r\n characters, my regex doesn't match it.

How can it make it work?


回答1:


Use single-line mode

http://msdn.microsoft.com/en-us/library/yd1hzczs.aspx#Singleline




回答2:


I don't know for sure if this works for RegEx'es as well,but you could try using Environment.NewLine in stead of \r\n.



来源:https://stackoverflow.com/questions/6179116/c-sharp-regex-match-any-text-between-tags-including-new-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!