簡體   English   中英

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

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

例如,每次出現字符串后,如何獲取所有文本,我必須遵循以下文本:

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

我怎樣才能做到這一點

{ "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