• Stars
    star
    1,121
  • Rank 39,880 (Top 0.9 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Extract urls from text

xurls

Go Reference

Extract urls from text using regular expressions. Requires Go 1.21 or later.

import "mvdan.cc/xurls/v2"

func main() {
	rxRelaxed := xurls.Relaxed()
	rxRelaxed.FindString("Do gophers live in golang.org?")  // "golang.org"
	rxRelaxed.FindString("This string does not have a URL") // ""

	rxStrict := xurls.Strict()
	rxStrict.FindAllString("must have scheme: http://foo.com/.", -1) // []string{"http://foo.com/"}
	rxStrict.FindAllString("no scheme, no match: foo.com", -1)       // []string{}
}

Since API is centered around regexp.Regexp, many other methods are available, such as finding the byte indexes for all matches.

The regular expressions are compiled when the API is first called. Any subsequent calls will use the same regular expression pointers.

cmd/xurls

To install the tool globally:

go install mvdan.cc/xurls/v2/cmd/xurls@latest
$ echo "Do gophers live in http://golang.org?" | xurls
http://golang.org

More Repositories

1

sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
Go
6,679
star
2

gofumpt

A stricter gofmt
Go
2,822
star
3

github-actions-golang

GitHub Actions as CI for Go
Go
1,013
star
4

interfacer

A linter that suggests interface types
Go
695
star
5

unparam

Find unused parameters in Go
Go
486
star
6

gogrep

Search for Go code using syntax trees
Go
475
star
7

fdroidcl

F-Droid desktop client
Go
239
star
8

goreduce

Reduce Go programs
Go
216
star
9

bitw

Minimalist BitWarden client
Go
159
star
10

zstd

Zstandard implementation in Wuffs
C
112
star
11

corpus

A corpus of popular Go modules
Go
100
star
12

dockexec

Run Go tests inside a Docker image
Go
96
star
13

benchinit

Benchmark the init cost of Go packages
Go
73
star
14

accesspoint

Manage wireless access points in Android (abandoned)
Java
73
star
15

pastecat

Pastebin service (abandoned)
Go
36
star
16

git-picked

List merged and cherry-picked branches
Go
29
star
17

winup

Automate a Windows 10 VM setup for coding and testing
Go
21
star
18

unindent

Report code that is unnecessarily indented
Go
18
star
19

android-template

Android app template
Java
16
star
20

dotfiles

Here be dragons
Shell
14
star
21

talks

Collection of slides from talks
Go
9
star
22

go-concurrency-workshop

Go
9
star
23

editorconfig

EditorConfig support in Go
Go
7
star
24

lint

Common interfaces for Go code checkers
Go
6
star
25

macfuzzer

Android MAC changer and randomizer (abandoned)
Java
6
star
26

gexf

GEXF file format implementation
Go
3
star
27

mvdan.cc

Personal website
HTML
3
star
28

playtyk

This repo is a temporary home for a hack.
Go
3
star
29

responsefile

Support for response files in Go, to bypass argument length limits
Go
2
star
30

tor

Consensus diffs Tor GSoC project
C
1
star
31

route

portable Go package to obtain simple routing information
Go
1
star
32

nowt

Nothing extraordinary here
Go
1
star
33

basedir

Platform-specific base directories
Go
1
star