Go: Retrieve a string from between two characters or other strings -
let's example have 1 string, this:
<h1>hello world!</h1>
what go code able extract hello world!
string? i'm still relatively new go. appreciated!
there lots of ways split strings in programming languages.
since don't know asking provide sample way output want sample.
package main import "strings" import "fmt" func main() { initial := "<h1>hello world!</h1>" out := strings.trimleft(strings.trimright(initial,"</h1>"),"<h1>") fmt.println(out) }
in above code trim <h1>
left of string , </h1>
right.
as said there hundreds of ways split specific strings , sample started.
hope helps, luck golang :)
db
Comments
Post a Comment