c# - Regex Beginning to End of a text file -


hi read text including <?xml version="1.0" encoding="iso-8859-1"?> </document> large text files. can need text start with <?xml version="1.0" encoding="iso-8859-1"?> , end </document>. mean separate xml part document. please me provide regex in c#

currently using following code :

if (text.contains("<?xml")) {     foreach (match match in regex.matches(text, @"(?s)<?xml(.*?)</document>"))     console.writeline(match.groups[1].value);     console.readkey(); } 

however not including .?xml... , ./document.

please advice

some of characters in regex not escaped , can use match group 0 include entire matched string. i've updated example below:

foreach (match match in regex.matches(text, @"(?s)\<\?xml(.*)</document>")) {    console.writeline(match.groups[0].value); } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -