Bug 291364 - Quotes are being added to links
Ahmed Ibrahim Khalil
ahmedibrahimkhali at gmail.com
Mon Jun 17 22:00:55 UTC 2013
Hi All,
I've taken a look at that bug. And also had taken a look at the mUrlRegExp
inside the PostWidget.cpp file.
I am not good at RegExps so I thought to jump and ask the guys in
Freenode's #regexp about a good regular expression, that matches this case
and doesn't append the trailing character to the url.
Thankfully, someone has told me a working one that fixes this bug you can
test it in the following link
http://regex101.com/r/iT2dA3
I know it is very different from the one inside the PostWidget.cpp . But I
thought in modifying to suit Choqok's case.
First I need to convert this regexp from PHPs implementation of PCRE to
Qt's QRegExp
I tried using this RegExp but it didnt match any URL
const QRegExp
PostWidget::mUrlRegExp("\b(?:(?:https?|ftp|file)://|(www|ftp)\\.)[-A-Z0-9+&@
#//%?=~_|$!:,.;]*[-A-Z0-9+&@#//%=~_|$]| \
\"(?:(?:https?|ftp|file)://|(www|ftp)\\.)[^\"\r\n]+\"|\"(?:(?:https?|ftp|file)://|(www|ftp)\\.)[^\"\r\n]+\"|
\
'(?:(?:https?|ftp|file)://|(www|ftp)\\.)[^'\r\n]+'", Qt::CaseInsensitive);
So If someone please could guide me to convert this regexp to QRegExp's
format as it would be much appreciated.
To understand the RegExp in the above link. It contains three alternations
1- \b(?:(?:https?|ftp|file):\/\/|(www|ftp)\.)[-A-Z0-9+&@
#\/%?=~_|$!:,.;]*[-A-Z0-9+&@#\/%=~_|$]
Matches any url without any trailing characters
2-
"(?:(?:https?|ftp|file):\/\/|(www|ftp)\.)[^"\r\n]+"|"(?:(?:https?|ftp|file):\/\/|(www|ftp)\.)[^"\r\n]+"
Matches any URLs surrounded by double quotation marks
3- '(?:(?:https?|ftp|file):\/\/|(www|ftp)\.)[^'\r\n]+'
Matches URL surrounded by single quotes.
Finally, If I said something wrong please correct me, Also any suggestions
would be much appreciated!
Cheers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/choqok-devel/attachments/20130618/e2f14289/attachment.html>
More information about the Choqok-devel
mailing list