Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Regular Expression #5

Closed
Rigter opened this issue Feb 27, 2013 · 1 comment
Closed

New Regular Expression #5

Rigter opened this issue Feb 27, 2013 · 1 comment

Comments

@Rigter
Copy link

Rigter commented Feb 27, 2013

I'm currently works with AMAttributedHighlightLabel, in some urls like this http://www.youtube.com/watch?v=iFNdGaN0P50 the regular expression has issues with some chars (in this case the question mark).

NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"((@|#)([A-Z0-9a-z(é|ë|ê|è|à|â|ä|á|ù|ü|û|ú|ì|ï|î|í)_]+))|(http(s)?://([A-Z0-9a-z._-]*(/)?)*)" options:NSRegularExpressionCaseInsensitive error:&error];

I've found a new regex for fix this issue:

NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"((@|#)([A-Z0-9a-z(é|ë|ê|è|à|â|ä|á|ù|ü|û|ú|ì|ï|î|í)_]+))|((?i)\\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`!()\\[\\]{};:'\".,<>?«»“”‘’])))" options:NSRegularExpressionCaseInsensitive error:&error];

Hope this helps for someone.

@rootd
Copy link
Owner

rootd commented Feb 27, 2013

thanks!

@rootd rootd closed this as completed Feb 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants