简体   繁体   English

获取字符串之后的所有文本,直到字符串下次出现?

[英]Get all text after a string until next occurrence of the string?

How can i get all the text after every occurrence of a string for example, I have to following text: 例如,每次出现字符串后,如何获取所有文本,我必须遵循以下文本:

commonstring
text and more text and more
random text that may or may 
not be on multiple lines
commonstring
more random text that
will be after the common string

How can I make that into an array of 我怎样才能做到这一点

{ "text and more text and more random text that may or may not be on multiple lines", "more random text that will be after the common string" } 

使用以下String.Split重载:

string[] parts = s.Split(new[] { "commonstring" }, int.MaxValue, StringSplitOptions.None);

您将要使用Regex.Split:

string[] result = Regex.Split(inputString, @"commonstring");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM