Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Go read url from file (change target to your desired domain)
package main
import (
"fmt"
"regexp"
"io/ioutil"
"log"
"os"
)
func main() {
argsWithoutProg := os.Args[1]
content, err := ioutil.ReadFile(argsWithoutProg)
if err != nil {
log.Fatal(err)
}
str1 := string(content)
re := regexp.MustCompile(`(https:\/\/www\.target\/?)([a-zA-Z0-9\-\.]){1,200}`)
//fmt.Printf("Pattern: %v\n", re.String()) // print pattern
//fmt.Println(re.MatchString(str1)) // true
submatchall := re.FindAllString(str1, -1)
for _, element := range submatchall {
fmt.Println(element)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment