c# - Extract text between ~ tags -
i have have following string:
~header1 content1 content2 content3 content4 ~header2 content5 content6 content7 content8 ~header3 content9 content10 content11 content12 ~header4
i need extract content between each header (~header
) using regular expression in c# language. how accomplish that?
i tried following code:
string pattern = "\\~.*\\~"; matchcollection matches = regex.matches(data , pattern, regexoptions.multiline ) ;
but not getting output.
so there array output, suppose name m
content:
m[0] = "~header1|content1|content2|content3|content4"; m[1] = "~header2|content5|content6|content7|content8"; etc
this trick
string[] m = regex.split(value1, @"(?=~header)").where(x => !string.isnullorempty(x)).toarray();
Comments
Post a Comment