perl escaper.pl helloworld
Created
August 15, 2018 19:43
-
-
Save DanyelMorales/689907b2e65861c08217c7920da6a87c to your computer and use it in GitHub Desktop.
Helloworld.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
undef $/; | |
$hostname = qr/[-a-z0-9]+(\.[-a-z0-9]+)*\.(com|edu|info)/; | |
$text = <>; | |
$text =~ s/&/&/g; | |
$text =~ s/</</g; | |
$text =~ s/>/>/g; | |
$text =~ s/^\s*$/<p>/mg; | |
$text =~ s{ | |
\b | |
# capture the address to one | |
( | |
\w[-.\w]* #username | |
\@ | |
$hostname #hostname | |
) | |
\b | |
}{<a href='mailto:$1'>$1</a>}igx; | |
$text =~ s{ | |
\b( | |
http:// $hostname #hostname | |
( | |
/[-a-z0-9_:\@&?=+,.!/~*'%\$]* | |
)? | |
)\b | |
}{ | |
<a href='$1'>$1</a> | |
}gix; | |
print $text; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Hello world, foobar,</h1> | |
<h2>test</h2> | |
dvera@sunset.com dvera@sunset.com | |
http://hello.com | |
http://hello-aaaa.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment