If you have some stringified version of HTML code, how can you verify that a particular substring sits within specific HTML tags? Say I need to verify that a substring sits in between a <p>
tag, <li>
tag, or <h2>
tag. For example:
stringifiedHTML = `<h2>Here is John Doe</h2>
<div>Hi my name is Jane Bob.</div>
<p>Joe Smith is my name.</p>
<button>Jen Willis</button>`
func betweenValidTags(input string, subStr string) bool {
// code to determine if valid
}
fmt.Println(betweenValidTags(stringifiedHTML, "John Doe")) // true
fmt.Println(betweenValidTags(stringifiedHTML, "Jane Bob")) // false
fmt.Println(betweenValidTags(stringifiedHTML, "Joe Smith")) // true
fmt.Println(betweenValidTags(stringifiedHTML, "Jen Willis")) // false