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
Post a Comment