Skip to content

Instantly share code, notes, and snippets.

@djadriano
Created January 16, 2013 19:41
Show Gist options
  • Save djadriano/4550153 to your computer and use it in GitHub Desktop.
Save djadriano/4550153 to your computer and use it in GitHub Desktop.
good regex tips
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