Debian Codegraph @

examples/demo_tokenre4

raw
1 #!/usr/bin/env runawk
2
3 #use "tokenre.awk"
4
5 # This demo extracts e-mails and URLs from input text and outputs them
6 # Using tokenre.awk for searching was inspired by talks with Vlad Shakhov
7
8 # Input files for this demo: examples/demo_tokenre3.in*
9
10 BEGIN {
11 # regexp for emails and URLs are just examples and therefore don't
12 # conform to appropriate RFCs.
13 domains = "(com|org|net|ru|by|ua)"
14 re = "[^ [:punct:]]+@([^ [:punct:]]+[.])+" domains
15 re = re "|" "(https?|ftp|dict)://([^ [:punct:]]+[.])+" domains "(/[^ [:punct:]]*)?"
16 }
17
18 {
19 cnt = splitre($0, arr, re)
20 for (i=1; i <= cnt; ++i){
21 if (i > 1)
22 printf " "
23 printf "%s", arr [i]
24 }
25 if (cnt)
26 printf "\n"
27 }