diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-07-09 08:25:35 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-07-09 08:25:35 +0200 |
| commit | ff99a09b4721f41da8a084b9717a05ba3b785067 (patch) | |
| tree | d9ed4fff04e051d1d43722a08a6b59557f0aa178 | |
| parent | 736fb0f46d52949d7582f86198a328743798a6f0 (diff) | |
| download | scripts-ff99a09b4721f41da8a084b9717a05ba3b785067.tar.gz scripts-ff99a09b4721f41da8a084b9717a05ba3b785067.zip | |
Attempt to write my own url regex
Diffstat (limited to '')
| -rwxr-xr-x | urlgrep | 9 |
1 files changed, 7 insertions, 2 deletions
| @@ -2,7 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | # Find all url in stdin, print them newline-separated to stdout | 3 | # Find all url in stdin, print them newline-separated to stdout |
| 4 | 4 | ||
| 5 | reg='(((http|https|ftp)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]' | 5 | # Old regex (PCRE), kept it for later review: |
| 6 | # reg='(((http|https|ftp)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]' | ||
| 7 | # grep -Po "$reg" | ||
| 6 | 8 | ||
| 7 | grep -Po "$reg" | 9 | protocols='http|https|ftp|gemini|mailto' |
| 10 | valid_chars="][a-zA-Z0-9_~/?#@!$&'()*+=.,;:-" | ||
| 11 | regex="(($protocols):|www\.)[$valid_chars]+" | ||
| 8 | 12 | ||
| 13 | egrep -o "$regex" | ||
