• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Search for a string in a HTML file c#

Is is possible to search out a string with a start and end and grab everything between?

It starts with

/content/

ends is

/NAME.tmp.x.xls


so I want to grab window.open('/content/RANDOMESTUFF/NAME.tmp.x.xls',

This is out of a html file and there can be anywhere from 1 to 30 entries that I need to grab.

Thanks
 
RegEx.Match(input, "pattern", RegexOption.MultiLine);

Research Regular Expressions and you'll find what you need. Write the correct pattern (something like "/content/[^']{0,}/Name.tmp.x.xls") and plug it in to a RegEx.Match call. You'll get an enumerable collection of Matches.
 
Regular expressions are a crude (but often effective under a naive presumption that there won't be false matches or markup interferences with true matches) way to do it.
If you want to be more specific in matching contextually relative to the markup and other elements of the HTML, you'd use a DOM / SCHEMA aware pattern matching setup. SAX, XML binding, ANTLR, XQUERY, XSLT, whatever.
 
Back
Top