#!/usr/bin/env runawk

#use "tokenre.awk"

# This demo extracts e-mails and URLs from input text and outputs them
# Using tokenre.awk for searching was inspired by talks with Vlad Shakhov

# Input files for this demo: examples/demo_tokenre3.in*

BEGIN { 
	# regexp for emails and URLs are just examples and therefore don't
	# conform to appropriate RFCs.
	domains = "(com|org|net|ru|by|ua)"
	TRE =         "[^ [:punct:]]+@([^ [:punct:]]+[.])+" domains
	TRE = TRE "|" "(https?|ftp|dict)://([^ [:punct:]]+[.])+" domains "(/[^ [:punct:]]*)?"
} 

{ 
	for (i=1; i <= NF; ++i){ 
		print $i 
	} 
}
