strings.TrimLeftFunc() Function in Golang With Examples
Last Updated :
10 May, 2020
strings.TrimLeftFunc() Function returns a slice of the string s with all leading Unicode code points c satisfying f(c) removed.
Syntax:
func TrimLeftFunc(s string, f func(rune) bool) string
Here, s is the string and func() is the method which satisfies the string characters.
Return Value: It returns the string after removing the leading characters from the string.
Example 1:
package main
import (
"fmt"
"strings"
"unicode"
)
func main() {
fmt.Print(strings.TrimLeftFunc( "77GeeksForGeeks!!!" , func(r rune) bool {
return !unicode.IsLetter(r)
}))
}
|
Output:
GeeksForGeeks!!!
Example 2:
package main
import (
"fmt"
"strings"
"unicode"
)
func main() {
fmt.Print(strings.TrimLeftFunc( "!!!34GeeksForGeeks!!!!" , func(r rune) bool {
return !unicode.IsLetter(r) && !unicode.IsNumber(r)
}))
}
|
Output:
34GeeksForGeeks!!!!
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...