Clean string from html content

There is a string, for instance

s := "<b>John</b> Thank you."

What is the best way to clean the string from

"<b>...</b>"

content?

For Python there is the broadly used Beautiful Soup.

For Go there is a port of this called soup. The method Text is what you are looking for.

I’m I understood you right that you supposed to get content of <b> tag? But what I want to get in result is to convert the source string into:

Thank you.

Hi @cinematik
Please, check this regular expression

package main

import (
“fmt”
“regexp”
)

const sample = <b>John</b>Thank you.<b>delete this</b>

func main() {
var re = regexp.MustCompile(<(b|B)>\b(([^<])*|(<[^b])*|(<b[^>])*)\b<\/(b|B)>)
s := re.ReplaceAllString(sample, ``)
fmt.Println(s)
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.