Regular Expressions 101

Community Patterns

1...45678...902

Community Library Entry

1

Regular Expression
.NET 7.0 (C#)

@"
<h\d{1}(?:.*?)>(?<title>.*?)<\/h\d{1}>
"
g

Description

Useful for matching/finding and capturing/extracting the titles of HTML heading elements. This was used to identify all heading elements within the body of a web page for the purposes of generating a Table of Contents for the page. Note: This expression could be altered for different HTML element tags (e.g. paragraph, div, etc.)

Submitted by Darius Liktorius - a year ago