| 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 |
TRE = "[^ [:punct:]]+@([^ [:punct:]]+[.])+" domains |
| 15 |
TRE = TRE "|" "(https?|ftp|dict)://([^ [:punct:]]+[.])+" domains "(/[^ [:punct:]]*)?" |
| 16 |
} |
| 17 |
|
| 18 |
{ |
| 19 |
for (i=1; i <= NF; ++i){ |
| 20 |
print $i |
| 21 |
} |
| 22 |
} |