Created
January 16, 2013 19:41
-
-
Save djadriano/4550153 to your computer and use it in GitHub Desktop.
good regex tips
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
localize the first and final line | |
start the line: ^ | |
end of the line: $ | |
replace www. to a tag: | |
\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’])) | |
<a href="http://\1" target="_blank">\1</a> | |
replace start and final the line: | |
^(.*)$ | |
<p>\1</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment