Skip to content

Instantly share code, notes, and snippets.

@mxcl
Created March 1, 2011 01:14
Show Gist options
  • Save mxcl/848410 to your computer and use it in GitHub Desktop.
Save mxcl/848410 to your computer and use it in GitHub Desktop.
C-string version of John Gruber’s URL Regex
#define TDURLRegularExpression "(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?\u00AB\u00BB\u201C\u201D\u2018\u2019]))"
@mxcl
Copy link
Author

mxcl commented Mar 1, 2011

Mainly you want this for the unicode characters at the end which most C compilers will barf over if you just copy and paste from the original source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment