How to extract text from between html tag using Regular Expressions in Golang?
Example
package main
import (
"fmt"
"regexp"
)
func main() {
str1 := `<html><body>
<form name="query" action="http://www.example.net/action.php" method="post">
<textarea type="text" name="nameiknow">The text I want</textarea>
<div id="button">
<input type="submit" value="Submit" />
</div>
</form>
</body></html>`
re := regexp.MustCompile(`<textarea.*?>(.*)</textarea>`)
submatchall := re.FindAllStringSubmatch(str1, -1)
for _, element := range submatchall {
fmt.Println(element[1])
}
}
Output
The text I want
Most Helpful This Week
Split a string at uppercase letters using regular expression in Golang
Regular expression to validate common Credit Card Numbers
Regular expression to validate email address
Regular expression to split string on white spaces
Regular expression to extract date(YYYY-MM-DD) from string
Regular expression to validate the date format in "dd/mm/yyyy"