Answer the question
In order to leave comments, you need to log in
How to find 1 domain from a string?
I have a string that contains a domain in the format: domen.com I want to find 1 domain from the text (continue searching until the first occurrence). Googled. could you help me?
expecting hgh.ru but getting h.ru
package main
import(
"fmt"
"regexp"
)
var re = regexp.MustCompile("[a-zа-я]\\.[a-zа-я]{2,6}")
func main(){
for _, value := range re.FindAllString("ghh hgh.ru", -1) {
fmt.Println(value)
}
}
Answer the question
In order to leave comments, you need to log in
search until the first occurrence:
FindStringSubmatch FindSubmatch
`
[
a-za-z]+\.[a-za-z]{2,6}` com/library/view/reg... or here myregexp.com/examples.html
+ add our [a-z]
And what domain zone should be? If there are several, then you need to list them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question