View previous topic :: View next topic |
Author |
Message |
R0b0t1 Apprentice
Joined: 05 Jun 2008 Posts: 264
|
Posted: Fri Jul 21, 2017 7:18 pm Post subject: Better URL Regex |
|
|
Hello,
Some valid URLs are not accepted by the regular expression (or other matching algorithm) the forum uses to detect URLs. This means that they can't be replaced with link text and that automatic hyperlinking might fail to link to the right page.
Examples:
[url=https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989(v=vs.85).aspx]Link Text[/url]
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989(v=vs.85).aspx |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22915
|
Posted: Sat Jul 22, 2017 12:26 am Post subject: |
|
|
Your criticism is correct, but there is a nuance. You can still link to such pages with explicit url tags if you manually escape the offending characters. In this case, the parentheses need to be changed to their escaped equivalents %28 and %29. This is not convenient, but it at least provides a way to use such links. |
|
Back to top |
|
|
Fitzcarraldo Advocate
Joined: 30 Aug 2008 Posts: 2056 Location: United Kingdom
|
Posted: Sat Jul 22, 2017 1:30 am Post subject: |
|
|
There are several Web sites for encoding and decoding URLs, but I quite like the following Python 2 command-line approach:
Code: | $ alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
$ alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' |
Code: | $ urlencode '(v=vs.85).aspx'
%28v%3Dvs.85%29.aspx |
Code: | $ urldecode '%28v%3Dvs.85%29.aspx'
(v=vs.85).aspx |
Beats trying to remember the percent codes.
Code: |
[url=https://msdn.microsoft.com/en-us/library/windows/desktop/ms644989%28v%3Dvs.85%29.aspx]Link Text[/url]
|
Ref. https://unix.stackexchange.com/a/159254 _________________ Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.
My blog |
|
Back to top |
|
|
|