<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Converting Windows file names to links]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">The windows file explorer returns strings like “D:\tmp\file.txt” when using the function “copy as path”. I want to transform such string into file:///D:/tmp/file.txt using a single regular expression. As a result Notepad++ can handle such link to open the file.</p>
<p dir="auto">I expect to have multiple file names each in a single line and no other characters present on lines containing a file name.</p>
<p dir="auto">My test data is this</p>
<pre><code>every line in this section must be changed
d:\
d:\ 
"d:\"
"d:\ "
d:\x\y\file.txt
"d:\ä\ö\straße.txt "
d:\x\y z\fi le.txt
d:/x/y z/file.txt
P:\
d:/dir with space
d:/trainling dir sep\

every line below must stay unchanged - look for missing "-characters
P:
x:
-:\
Ä:\
ä:\
\
 d:\
"d:\dir
"d:/dir with space
p:\dir"
d:x\y\file.txt
this is a test
</code></pre>
<p dir="auto">The expected result is</p>
<pre><code>every line in this section must be changed
file:///d:/
file:///d:/%20
file:///d:/
file:///d:/%20
file:///d:/x/y/file.txt
file:///d:/ä/ö/straße.txt%20
file:///d:/x/y%20z/fi%20le.txt
file:///d:/x/y%20z/file.txt
file:///P:/
file:///d:/dir%20with%20space
file:///d:/trainling dir separator/

every line below must stay unchanged - look for missing "-characters
P:
x:
-:\
Ä:\
ä:\
\
 d:\
"d:\dir
"d:/dir with space
p:\dir"
d:x\y\file.txt
this is a test
</code></pre>
<p dir="auto">Currently I am using the following regex for find</p>
<pre><code>^("?)(?&lt;fn&gt;[a-zA-Z]:[\\/][^:\*"&lt;&gt;\|]*?)\1$
</code></pre>
<p dir="auto">and this string in replace:</p>
<pre><code>file:///$+{fn}
</code></pre>
<p dir="auto">In my opinion this first step is not too bad. But I do not discover how to replace spaces and black slashes ind the fn group.</p>
<p dir="auto">To install the python script plugin is not an option as i am not the administrator. I already considered to use NppExec plugin but with no success.</p>
<p dir="auto">Any ideas?</p>
<p dir="auto">Kind Regards<br />
Thomas</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/23440/converting-windows-file-names-to-links</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Jul 2026 21:56:34 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/23440.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Sep 2022 09:16:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Converting Windows file names to links on Thu, 29 Sep 2022 15:28:15 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for all your help. I appreciate it.</p>
<p dir="auto">When using this macro in my environment it work really fine.</p>
<p dir="auto">I figured out an additional requirement while using it: The macro must leave already converted links untouched. This requirement is already fulfilled in my opinion because either S/R <code>A</code> and S/R <code>B</code> will not match any more.</p>
<p dir="auto">This is really useful!</p>
<p dir="auto">Regards<br />
Thomas</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80166</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80166</guid><dc:creator><![CDATA[tho-gru]]></dc:creator><pubDate>Thu, 29 Sep 2022 15:28:15 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Thu, 15 Sep 2022 18:56:17 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Oh, my god ! I’m terribly <strong>sorry</strong> because I haven’t noticed that the <strong><code>\</code></strong> character was <strong>not</strong> properly displayed in regex <strong><code>A</code></strong> :-((</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a>, you said :</p>
<blockquote>
<p dir="auto">I finally find the (or my) error…</p>
</blockquote>
<p dir="auto">It’s definitively not <strong>your</strong> error, It’s <strong>mine</strong> :-(</p>
<p dir="auto">Most of the time, due to our <strong>forum</strong> and/or <strong>Markdown</strong> syntax some characters need to be changed into their <strong>escape</strong> syntax when expressed in <strong>regexes</strong>.</p>
<p dir="auto">So :</p>
<ul>
<li>
<p dir="auto">When you search for a <strong>literal</strong> <strong><code>[</code></strong> char, use preferably the <strong><code>\x5B</code></strong> syntax</p>
</li>
<li>
<p dir="auto">When you search for a <strong>literal</strong> <strong><code>\</code></strong> char, use preferably the <strong><code>\x5C</code></strong> syntax</p>
</li>
<li>
<p dir="auto">When you search for a <strong>literal</strong> <strong><code>]</code></strong> char, use preferably the <strong><code>\x5D</code></strong> syntax</p>
</li>
<li>
<p dir="auto">When you search for a <strong>literal</strong> <strong><code>backtick</code></strong> char, use preferably the <strong><code>\x60</code></strong> syntax</p>
</li>
</ul>
<hr />
<p dir="auto">Of course, in the regex <strong><code>A</code></strong>, the parts <strong><code>[/\x5C]</code></strong> and <strong><code>[/"\x5C]</code></strong> are real <strong>class</strong> characters, so the <strong><code>[</code></strong> and <strong><code>]</code></strong> are <strong>not literal</strong> chars but a <strong>specific</strong> regex syntax !</p>
<p dir="auto">Again, sorry for my <strong>mistake</strong> which must have made you look for a <strong>long</strong> time !</p>
<hr />
<p dir="auto">So, here is the <strong>correct</strong> version of my <strong>old</strong> post :</p>
<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">I would like, first, to give some information about <strong>pathnames</strong>, <strong>space</strong> chars in files or folders and <strong>characters</strong> that need the <strong><code>%nn</code></strong> syntax in links</p>
<hr />
<p dir="auto">When using a <strong>DOS</strong> command <strong>prompt</strong>, you can define a <strong>full</strong> pathname with, either, <strong><code>\</code></strong> ( <strong>anti-slash</strong> ) or <strong><code>/</code></strong> ( <strong>slash</strong> ) characters or a <strong>mix</strong> of them ! Of course, when you use <strong>normal</strong> slashs, the <strong>auto-completion</strong> mechanism with the <strong><code>TAB</code></strong> key, of folders or files, will <strong>not</strong> work.</p>
<p dir="auto">In summary, the lines <strong><code>C:\my folder\My file.txt</code></strong> and <strong><code>C:/my folder/My file.txt</code></strong> are totally <strong>equivalent</strong></p>
<hr />
<p dir="auto">Usually, when creating a file from the <strong>explorer</strong>, you may include any <strong>space</strong> char inside, but not at the <strong>very beginning</strong> or at the <strong>very end</strong> of a file or folder. However, if you’ve opened a <strong>DOS</strong> command <strong>prompt</strong> and use the DOS <strong><code>ren</code></strong> command, you may use the following command :</p>
<pre><code class="language-diff">ren File.txt "   Fi  le  .  txt   " which will rename the "File.txt" file as "   Fi  le  .  txt"
</code></pre>
<p dir="auto">As you can see, <strong>trailing</strong> spaces, after any text, in files or folders, are <strong>not</strong> allowed but you may insert <strong>space</strong> char(s) at any <strong>other</strong> location !</p>
<hr />
<p dir="auto">Given the regex, used in notepad++, to detect links, I tried to identify <strong>all</strong> the characters which need the <strong><code>%nn</code></strong> syntax, like <strong><code>%20</code></strong> to replace any <strong>space</strong> char. After some tries, it happens that only <strong>two</strong> other chars need to be changed, using <strong><code>%nn</code></strong>. So, the complete list is :</p>
<pre><code class="language-diff">    SPACE    %20
    {        %7B
    }        %7D
</code></pre>
<p dir="auto">Now, given all these <strong>preliminary</strong> elements, we can build a <strong>regex</strong> to change any <strong>full</strong> pathmane into a valid <strong>hyperlink</strong> ! I assume <strong>two</strong> hypotheses :</p>
<ul>
<li>
<p dir="auto">Only <strong>one full</strong> pathname per line</p>
</li>
<li>
<p dir="auto">Each pathmane <strong>begins</strong> and <strong>ends</strong> its current line</p>
</li>
</ul>
<hr />
<p dir="auto">So, here is a TEST sheet, which explains what must be <strong>matched</strong> or <em>not</em> matched :</p>
<pre><code class="language-diff">- The regex must MATCH the following lines :

d:\                                        #  FULL pathname WITHOUT quotes
"d:\"                                      #  FULL pathname with QUOTES
d:\x\y\file.docx                           #  FULL pathname with SEVERAL levels of SUBDIRS and a final WORD document
"d:\ä\ö\straße.txt "                       #  FULL pathname with folders with ACCUENTUATED characters and a SPACE char before the ENDING quote
d:/x/y z/file.txt                          #  FULL pathname with a SUBFOLDER containing a SPACE and / SEPARATORS
d:\x\y z\fi le.xlsx                        #  FULL pathname with a SUBFOLDER and the FILENAME containing a SPACE and an EXCEL sheet
C:\                                        #  FULL pathname with a DIFFERENT DRIVE letter
"D:\_DEF\  XY   Z"                         #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and WITHIN its name
"D:\_DEF\  XY   Z\"                        #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and WITHIN its name and a TRAILING anti-slash
"D:/_DEF/  XY   Z"                         #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and WITHIN its name and / SEPARATORS
"D:/_DEF/  XY   Z/"                        #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and WITHIN its name and / SEPARATORS and a TRAINLING slash
"D:\_DEF\  XY   Z\  AB   C  .   txt"       #  FULL pathname with a SUBDIR and the FILE name containing LEADING and MIDDLE spaces
"D:/_DEF/  XY   Z/  AB   C  .   txt"       #  FULL pathname with a SUBDIR and the FILE name containing LEADING and MIDDLE spaces and / SEPARATORS
"D:\_DEF\  XY   Z\RST"                     #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and INSIDE its name and a FILE name WITHOUT extension
"D:/_DEF/  XY   Z/RST"                     #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and INSIDE its name and a FILE name WITHOUT extension
D:\@@\792\!#$%&amp;'()+,-.;@[]^_` {}~€à×.txt   #  FULL pathname with SEVERAL levels of SUBDIRS and a FILE name with ALL symbols between 0X20 and 0x7F plus €à× &gt; 0X7F
D:/@@/792/!#$%&amp;'()+,-.;@[]^_` {}~€à×.txt   #  FULL pathname with SEVERAL levels of SUBDIRS and a FILE name with ALL symbols between 0X20 and 0x7F plus €à× &gt; 0X7F and / SEPARATORS
"d:\x\y\z\abc.txt   "                      #  FULL pathmane with SEVERAL levels of SUBDIRS and TRAILING SPACES after the file EXTENSION

- The regex must NOT match any of the following lines :

d:\                                        #  With a TRAILING space, leading to file:///d:\%20 , identical to file:///d:\
x:                                         #  NO slash NOR anti-slash, after the COLON
-:\                                        #  NO DRIVE letter
Ä:\                                        #  FORBIDDEN drive value 
ä:\                                        #  FORBIDDEN drive value 
\                                          #  NO DRIVE letter and NO COLON
 d:\                                       #  SPACE beginning the FULL pathname
"d:\dir                                    #  TRAILING double quote MISSING
"d:/dir with space                         #  TRAILING double quote MISSING
p:\dir"                                    #  LEADING  double quote missing
d:x\y\file.txt                             #  SLASH or ANTISLASH MISSING after the COLON
this is a test                             #  NO FULL pathname
d:\x\y  \z\abc.txt                         #  Trailing SPACES at END of the Y SUBdirectory
"d:\x\y  \z\abc.txt"                       #  Trailing SPACES at END of the Y SUBdirectory
</code></pre>
<hr />
<p dir="auto">As we suppose that <strong>only one</strong> <em>FULL</em> pathmane must appear on <strong>each</strong> line, this leads to the following <em>INPUT</em> text :</p>
<pre><code class="language-diff">d:\
"d:\"
d:\x\y\file.docx
"d:\ä\ö\straße.txt "
d:/x/y z/file.txt
d:\x\y z\fi le.xlsx
C:\
"D:\_DEF\  XY   Z"
"D:\_DEF\  XY   Z\"
"D:/_DEF/  XY   Z"
"D:/_DEF/  XY   Z/"
"D:\_DEF\  XY   Z\  AB   C  .   txt"
"D:/_DEF/  XY   Z/  AB   C  .   txt"
"D:\_DEF\  XY   Z\RST"
"D:/_DEF/  XY   Z/RST"
D:\@@\792\!#$%&amp;'()+,-.;@[]^_` {}~€à×.txt
D:/@@/792/!#$%&amp;'()+,-.;@[]^_` {}~€à×.txt
"d:\x\y\z\abc.txt   "

d:\ 
x:
-:\
Ä:\
ä:\
\
 d:\
"d:\dir
"d:/dir with space
p:\dir"
d:x\y\file.txt
this is a test
d:\x\y  \z\abc.txt
"d:\x\y  \z\abc.txt"
</code></pre>
<p dir="auto"><strong>Beware</strong> : the second <strong><code>d:\</code></strong> is followed with a <strong>space</strong> char, =&gt; NO match</p>
<hr />
<p dir="auto">We need <strong>two</strong> regexes S/R in order to get <strong>functional</strong> hyperlinks :</p>
<ul>
<li>
<p dir="auto">The <strong>first</strong> S/R <strong><code>A</code></strong> will transform any <strong>FULL</strong> pathname into an <strong>hyperlink</strong>, beginning with the syntax <strong><code>file:///</code></strong></p>
</li>
<li>
<p dir="auto">The <strong>second</strong> S/R <strong><code>B</code></strong> will replace <strong>any</strong> character <strong>SPACE</strong>,<strong><code>{</code></strong> and <strong><code>}</code></strong> with, respectively, the strings <strong><code>%20</code></strong>, <strong><code>%7B</code></strong> and <strong><code>%7D</code></strong>, <strong>only</strong> on lines beginning with the <strong><code>file:///</code></strong> syntax</p>
</li>
</ul>
<p dir="auto">I will use the <strong>free-spacing</strong> mode <strong><code>(?x)</code></strong>, in the <strong>search</strong> regexes, to <strong>better</strong> visualize the different regex parts. So :</p>
<ul>
<li>The S/R <strong>A</strong> is :</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?xi) ^ (")? ( [A-Z] : [/\x5C] (?: (?: (?![/"\x5C]) \S | \x20 )* (?![/"\x5C]) \S [/\x5C] )* (?: (?: (?![/"\x5C]) \S | \x20 )* (?![/"\x5C]) \S )? ) (?(1)\x20*")  $</code></strong></p>
<p dir="auto">REPLACE  <strong><code>file:\x2F\x2F\x2F\2</code></strong></p>
<ul>
<li>The S/R <strong>B</strong> is :</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?x-is) ^ (?!file:/{3}) .+ (*SKIP) (*FAIL) | ( \x20 ) | ( { ) | ( } )</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1%20)(?2%7B)(?3%7D)</code></strong></p>
<hr />
<p dir="auto">Then, the road map is :</p>
<ul>
<li>
<p dir="auto">Select the zone containing <strong>all</strong> your <strong>full</strong> pathnames list, which will be changed into <strong>hyperlinks</strong></p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
<ul>
<li>
<p dir="auto">Hit the <strong><code>Del</code></strong> key to clear the <strong><code>Find what:</code></strong> zone</p>
</li>
<li>
<p dir="auto">Check the <strong><code>In selection</code></strong> option</p>
</li>
<li>
<p dir="auto">SEARCH <strong><code>(?xi) ^ (")? ( [A-Z] : [/\x5C] (?: (?: (?![/"\x5C]) \S | \x20 )* (?![/"\x5C]) \S [/\x5C] )* (?: (?: (?![/"\x5C]) \S | \x20 )* (?![/"\x5C]) \S )? ) (?(1)\x20*")  $</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE  <strong><code>file:\x2F\x2F\x2F\2</code></strong></p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search <strong>mode</strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; A message appears : <strong><code>Replace All: 18 occurrences were replaced in selected text</code></strong></p>
<ul>
<li>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?x-is) ^ (?!file:/{3}) .+ (*SKIP) (*FAIL) | ( \x20 ) | ( { ) | ( } )</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>(?1%20)(?2%7B)(?3%7D)</code></strong></p>
</li>
<li>
<p dir="auto">Click again on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; A message appears : <strong><code>Replace All: 69 occurrences were replaced in selected text</code></strong></p>
<p dir="auto">And it gives the <strong>expected</strong> <em>OUTPUT</em> text :</p>
<pre><code class="language-diff">file:///d:\
file:///d:\
file:///d:\x\y\file.docx
file:///d:\ä\ö\straße.txt
file:///d:/x/y%20z/file.txt
file:///d:\x\y%20z\fi%20le.xlsx
file:///C:\
file:///D:\_DEF\%20%20XY%20%20%20Z
file:///D:\_DEF\%20%20XY%20%20%20Z\
file:///D:/_DEF/%20%20XY%20%20%20Z
file:///D:/_DEF/%20%20XY%20%20%20Z/
file:///D:\_DEF\%20%20XY%20%20%20Z\%20%20AB%20%20%20C%20%20.%20%20%20txt
file:///D:/_DEF/%20%20XY%20%20%20Z/%20%20AB%20%20%20C%20%20.%20%20%20txt
file:///D:\_DEF\%20%20XY%20%20%20Z\RST
file:///D:/_DEF/%20%20XY%20%20%20Z/RST
file:///D:\@@\792\!#$%&amp;'()+,-.;@[]^_`%20%7B%7D~€à×.txt
file:///D:/@@/792/!#$%&amp;'()+,-.;@[]^_`%20%7B%7D~€à×.txt
file:///d:\x\y\z\abc.txt

d:\ 
x:
-:\
Ä:\
ä:\
\
 d:\
"d:\dir
"d:/dir with space
p:\dir"
d:x\y\file.txt
this is a test
d:\x\y  \z\abc.txt
"d:\x\y  \z\abc.txt"
</code></pre>
<p dir="auto">IMPORTANT : When you <strong>double</strong> -click on an <strong>hyperlink</strong>, containing an <strong>existing</strong> file, it <strong>automatically</strong> opens in its <strong>default</strong> application =&gt; For instance, any <strong><code>.docx</code></strong> is lauched with Microsoft <strong>Word</strong> and any <strong><code>.xlsx</code></strong> starts with Microsoft <strong>Excel</strong> !</p>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>For the <strong>first</strong> S/R <strong><code>A</code></strong>, we can, as well, split over the <strong>search</strong> regex, in <strong>several</strong> lines, like below :</li>
</ul>
<pre><code class="language-diff">(?xi)
^  (")?                                                        #  An OPTIONAL leading quote at BEGINNING of line, stored in Group 1
(                                                              #  START of Group 2
[A-Z]  :  [/\x5C]                                              #  DRIVE letter, colon and SLASH or ANTI-SLASH
(?: (?: (?![/"\x5C]) \S | \x20 )* (?![/"\x5C]) \S  [/\x5C] )*  #  OPTIONAL SUBSEQUENT subfolder(s) chars, ending with a NON-SPACE char, before a SLASH or ANTI-SLASH
(?: (?: (?![/"\x5C]) \S | \x20 )* (?![/"\x5C]) \S )?           #  OPTIONAL NON-SPACE or SPACE chars, ending with a NON-SPACE char ( LAST subfolder or FOLE NAME part )
)                                                              #  END of Group 2
(?(1)\x20*")  $                                                #  OPTIONAL SPACES and the ENDING quote ( if LEADING quote at START ), before the END of CURRENT line
</code></pre>
<ul>
<li>Regarding the <strong>second</strong> S/R <strong><code>B</code></strong>, we could also have used this other <strong>search</strong> version, for <strong>same</strong> results :</li>
</ul>
<p dir="auto"><strong><code>(?x-is) (?: ^file:/{3} | (?!\A)\G ) .*? \K (?: ( \x20 ) | ( { ) | ( } ) )</code></strong></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> : This method works for <strong>both</strong> <strong><code>ANSI</code></strong> and <strong><code>UTF-8</code></strong> / <strong><code>UTF-8-BOM</code></strong> encodings !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79722</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79722</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 15 Sep 2022 18:56:17 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Mon, 12 Sep 2022 19:43:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a> said in <a href="/post/79716">Converting Windows file names to links</a>:</p>
<blockquote>
<p dir="auto">It often complain about spam suspicious posts</p>
</blockquote>
<p dir="auto">I think you mean “It rarely complains about spam suspicious posts”.  In my ~6000 posts here, I have seen it only a handful of times (around 1 time per thousand).  That doesn’t seem a bad tradeoff for the number of times the Akismet filter has  <em>caught</em> posts which contains huge amounts of spam, or someone trying to post the contents of a binary file (presumably trying to upload a virus or similar).  It’s a tradeoff that the Administrators are willing to make.</p>
<blockquote>
<p dir="auto">The 5 minute limit affects everyone</p>
</blockquote>
<p dir="auto">And some of us more often than others. ;-)  (I am notorious for finding typos after I post.)</p>
<p dir="auto">I recently checked the forum settings: unfortunately, there is no way to enable the feature I’d really want: “you are allowed to edit your post until someone has replied”.  The 5 minute timeout is the most reasonable compromise we can make between giving people long enough to fix typos and making sure that people don’t change history (otherwise, a nefarious user could say something innocuous, encouraging other users to chime in with “I agree”, and then go back and change the statement to something completely different, which makes the whole conversation a lie)</p>
<p dir="auto">And despite saying, a few minutes ago, that <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> <em>could</em> go back and edit his older posts to fix the regex, at this point, it would make much more sense in the context of the discussion, for Guy to make a <em>new</em> reply post, with the regex fixed to use <code>\x5D</code> instead of trying to get the forum to handle backslash-closeSquareBracket correctly.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79720</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79720</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 12 Sep 2022 19:43:54 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Mon, 12 Sep 2022 19:29:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a> said:</p>
<blockquote>
<p dir="auto">This forum software is quite ugly to use. It often complain about spam suspicious posts and only left 5 minutes to edit.</p>
</blockquote>
<p dir="auto">It may complain about certain things until you have a reputation &gt;= 2.</p>
<p dir="auto">The 5 minute limit affects everyone.  It’s not so bad.  It encourages you to proofread what you write before posting.  If you see an error later (passed the time limit), simply post again and say the error and the correction.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79719</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79719</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 12 Sep 2022 19:29:08 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Mon, 12 Sep 2022 19:28:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> ,</p>
<blockquote>
<p dir="auto">avoid the bug: <code>0x5D</code></p>
</blockquote>
<p dir="auto">I think you mean <code>\x5D</code> ;-)</p>
<blockquote>
<p dir="auto">I hope a moderator comes along and straightens it out.</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> has the moderator power necessary to go back and edit his own posts, to have the regex use a reasonable escape of <code>\x5D</code> instead of trying to get the backslash-closebracket to go through this forum correctly.  I am not about to try to edit a guy-regex for republishing, because I’d never know if I broke it while trying to edit it. ;-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79718</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79718</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Mon, 12 Sep 2022 19:28:36 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Mon, 12 Sep 2022 19:26:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a></p>
<p dir="auto">This thread is hopelessly muddled.<br />
I hope a moderator comes along and straightens it out.</p>
<blockquote>
<p dir="auto">the character combinations backslash followed by closing square bracket must be converted to backslash, backslash followed by closing square bracket</p>
</blockquote>
<p dir="auto">Yes, there is a website bug with the backslash-closingSquareBracket sequence.  It is better to use the following for the closingSquareBracket to avoid the bug: <code>0x5D</code>.</p>
<p dir="auto">Guy knows about this bug and I would have thought his earlier postings would not have included such problems.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79717</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79717</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 12 Sep 2022 19:26:30 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Mon, 12 Sep 2022 19:21:02 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> and everyone,</p>
<p dir="auto">I finally find the (or my) error…</p>
<p dir="auto">When I use the regex A from guy is does not work. After watching some additional time on the regex I simply guess that the character combinations backslash followed by closing square bracket must be converted to backslash,  backslash followed by closing square bracket.</p>
<p dir="auto">Even the live preview looks different than the final post.</p>
<p dir="auto">Unfortunately while trying to provide some text representation of the new regex failed. Here is a screen shot:<br />
<img src="/assets/uploads/files/1663010121998-notepad-filename2link.png" alt="Notepad++Filename2Link.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">So perhaps the solution provided by guy is now more useful for other people.</p>
<p dir="auto">PS: This forum software is quite ugly to use. It often complain about spam suspicious posts and only left 5 minutes to edit. Therefore the repost.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79716</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79716</guid><dc:creator><![CDATA[tho-gru]]></dc:creator><pubDate>Mon, 12 Sep 2022 19:21:02 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Mon, 12 Sep 2022 19:03:32 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> and everyone,</p>
<p dir="auto">I finally find the (or my) error…</p>
<p dir="auto">When I use the regex A from guy is does not work. After watching some additional time on the regex I simply guess that the character combinations \] must be converted to \\] (when writing this text the preview function shows that \-chars must be entered twice to appear in the preview).</p>
<p dir="auto">This following regex works for me:</p>
<pre><code>(?xi) ^ (")? ( [A-Z] : [/\\\\] (?: (?: (?![/"\\\\]) \S | \x20 )* (?![/"\\\\]) \S [/\\\\] )* (?: (?: (?![/"\\\\]) \S | \x20 )* (?![/"\\\\]) \S )? ) (?(1)\x20*") $
</code></pre>
<p dir="auto">So perhaps the solution provided by guy is now more useful for other people.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79715</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79715</guid><dc:creator><![CDATA[tho-gru]]></dc:creator><pubDate>Mon, 12 Sep 2022 19:03:32 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Wed, 07 Sep 2022 12:33:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">First of all, I want to <strong>apologize</strong> about an obvious <strong>error</strong>, in the Regex <strong><code>A</code></strong> <strong>Replacement</strong> part :</p>
<p dir="auto">I said :</p>
<pre><code class="language-diff">REPLACE file///\2
</code></pre>
<p dir="auto">Of course, the <strong>correct</strong> regex is</p>
<p dir="auto">REPLACE <strong><code>file:///\2</code></strong></p>
<p dir="auto">Secondly, to <strong>avoid</strong> that this regex, itself, to be an <strong>hyperlink</strong>, I prefered this <strong>final</strong> syntax :</p>
<p dir="auto">REPLACE <strong><code>file:\x2F\x2F\x2F\2</code></strong></p>
<p dir="auto"><strong>Important</strong> : I <strong>updated</strong> my <strong>previous</strong> post, accordingly, in order the info to be <strong>accurate</strong> !</p>
<hr />
<p dir="auto">Now regarding your problem, I first noticed that your regex is <strong>not</strong> the same as mime, as its just considers the case of <strong>pathnames</strong> with <strong>slashs</strong> only, like in <strong><code>D:/ABC/xYZ.txt</code></strong></p>
<p dir="auto">But, even with this <strong>restriction</strong>, if I run your regex against the <em>INPUT</em> text, provided in my <strong>previous</strong> post, I <strong>did</strong> get <strong><code>6</code></strong> replacements, relative to <strong>all</strong> the pathnames with usual <strong><code>/</code></strong> of the test <strong>list</strong> !</p>
<p dir="auto">So, I don’t know why you found a <strong>malformed</strong> regex expression ?</p>
<p dir="auto"><img src="/assets/uploads/files/1662553913841-00978f72-9cc2-4152-812a-f278413d3636-test.png" alt="00978f72-9cc2-4152-812a-f278413d3636-Test.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Notepad++ v8.4.4   (64-bit)<br />
Build time : Jul 15 2022 - 17:54:42<br />
Path : E:\844_x64\notepad++.exe<br />
Command Line :<br />
Admin mode : OFF<br />
Local Conf mode : ON<br />
Cloud Config : OFF<br />
OS Name : Windows 10 Pro (64-bit)<br />
OS Version : 21H2<br />
OS Build : 19044.1949<br />
Current ANSI codepage : 1252<br />
Plugins :<br />
mimeTools (2.8)<br />
NppConverter (4.4)<br />
NppExport (0.4)<br />
ComparePlus (1)</p>
<hr />
<p dir="auto">If you use the <strong>complete</strong> regex S/R <strong><code>A</code></strong>, given ( and <strong>updated</strong> ) in my <strong>previous</strong> post, you should get <strong><code>18</code></strong> replacements, as before !</p>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79583</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79583</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 07 Sep 2022 12:33:56 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Wed, 07 Sep 2022 12:00:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a> said in <a href="/post/79581">Converting Windows file names to links</a>:</p>
<blockquote>
<p dir="auto">When I click on find I got the message that the regex is syntactically wrong.<br />
Can you please tell me, what i did wrong?</p>
</blockquote>
<p dir="auto">Well, this is dangerously close to expecting other people to do your work for you.  I mean, if you get into that situation, you should remove stuff from your expression slowly, experimenting, and at some point you’ll see what you did wrong.  Then you can slowly add back in, testing, and get your expression correct.</p>
<p dir="auto">But… If I copy your expression and press <em>Find Next</em>, I get no message about it being “syntactically wrong”.  I get “Can’t find the text…” which means the syntax is correct.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79582</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79582</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 07 Sep 2022 12:00:53 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Wed, 07 Sep 2022 05:57:23 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a>,</p>
<p dir="auto">I use notepad++:<br />
##################################<br />
Notepad++ v8.4.4   (64-bit)<br />
Build time : Jul 15 2022 - 17:54:42<br />
Path : C:\Program Files\Notepad++\notepad++.exe<br />
Command Line : -multiInst<br />
Admin mode : OFF<br />
Local Conf mode : OFF<br />
Cloud Config : OFF<br />
OS Name : Windows 10 Pro (64-bit)<br />
OS Version : 21H2<br />
OS Build : 19044.1889<br />
Current ANSI codepage : 1252<br />
Plugins :<br />
ComparePlugin (2.0.2)<br />
DSpellCheck (1.4.24)<br />
JSMinNPP (1.2205)<br />
mimeTools (2.8)<br />
NppConverter (4.4)<br />
NppExec (0.8)<br />
NppExport (0.4)<br />
PythonScript (2)<br />
XMLTools (3.1.1.13)<br />
##################################</p>
<p dir="auto">I copied S/R A into the replace dialog:</p>
<pre><code>(?xi) ^ (")? ( [A-Z] : [/\] (?: (?: (?![/"\]) \S | \x20 )* (?![/"\]) \S [/\] )* (?: (?: (?![/"\]) \S | \x20 )* (?![/"\]) \S )? ) (?(1)\x20*") $
</code></pre>
<p dir="auto">When I click on replace all nothing hapens.</p>
<p dir="auto">When I click on find I got the message that the regex is syntactically wrong:<br />
<img src="/assets/uploads/files/1662530027542-20220907-075132-ersetzen.png" alt="20220907-075132-Ersetzen.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Can you please tell me, what i did wrong?</p>
<p dir="auto">Kind Regards<br />
Thomas</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79581</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79581</guid><dc:creator><![CDATA[tho-gru]]></dc:creator><pubDate>Wed, 07 Sep 2022 05:57:23 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Tue, 06 Sep 2022 12:31:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a> said in <a href="/post/79566">Converting Windows file names to links</a>:</p>
<blockquote>
<p dir="auto">When recording a macro using the find dialog</p>
<p dir="auto">How to activate the regex checkbox when not knowing its state?<br />
How to restore the regex flag in the dialog at the end of the macro?</p>
</blockquote>
<p dir="auto">Don’t worry about these things.  Record your macro using the UI settings you need.  When your macro is run by the user, it uses the settings without changing anything in the user interface.</p>
<p dir="auto">Don’t think of it like if you record a bunch of replacement actions into a macro and then play the macro while watching the Replace window, thinking you’ll see things change really fast in the window, and be left with the setup from the final replace in the macro – doesn’t work that way.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79570</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79570</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 06 Sep 2022 12:31:44 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Tue, 06 Sep 2022 12:28:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a> said in <a href="/post/79565">Converting Windows file names to links</a>:</p>
<blockquote>
<p dir="auto">Is there an option to transfer a macro from one to another Notepad++ installation?</p>
</blockquote>
<p dir="auto">Yes, in <code>shortcuts.xml</code> macros appear between &lt;Macro&gt; and &lt;/Macro&gt; tags.  You may copy textually from one file (on one PC) into another copy of the file (from a different PC) if you heed the advice <a href="https://npp-user-manual.org/docs/config-files/#:~:text=AppData%25%5CNotepad%2B%2B%5C.-,Editing%20Configuration%20Files,-ALWAYS%20BACKUP%20THE" rel="nofollow ugc">HERE</a> in the user manual.  Also note that you can just take the ENTIRE file if you want that level of identicality.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79569</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79569</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 06 Sep 2022 12:28:45 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Tue, 06 Sep 2022 11:34:58 GMT]]></title><description><![CDATA[<p dir="auto">Re: <a href="/topic/23440/converting-windows-file-names-to-links">Converting Windows file names to links</a></p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> thanks for your supposed solution.</p>
<p dir="auto">These is some details i am thinking about: When recording a macro using the find dialog</p>
<ul>
<li>How to activate the regex checkbox when not knowing its state?</li>
<li>How to restore the regex flag in the dialog at the end of the macro?</li>
</ul>
<p dir="auto">The background is, I want to distribute this macro to my colleagues who perhaps do not know anything about the regex flag.</p>
<p dir="auto">PS: In the thread <a href="https://community.notepad-plus-plus.org/topic/15562/how-to-share-a-recorded-marco-with-others">how-to-share-a-recorded-marco-with-others</a> i found the solution for copying macros between notepad++ installations.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79566</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79566</guid><dc:creator><![CDATA[tho-gru]]></dc:creator><pubDate>Tue, 06 Sep 2022 11:34:58 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Tue, 06 Sep 2022 11:04:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a></p>
<p dir="auto">That is a good idea. I did not know that is is possible with macros to set values in search an replace dialog. Is there an option to transfer a macro from one to another Notepad++ installation?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79565</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79565</guid><dc:creator><![CDATA[tho-gru]]></dc:creator><pubDate>Tue, 06 Sep 2022 11:04:21 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Mon, 12 Sep 2022 21:52:09 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">I would like, first, to give some information about <strong>pathnames</strong>, <strong>space</strong> chars in files or folders and <strong>characters</strong> that need the <strong><code>%nn</code></strong> syntax in links</p>
<hr />
<p dir="auto">When using a <strong>DOS</strong> command <strong>prompt</strong>, you can define a <strong>full</strong> pathname with, either, <strong><code>\</code></strong> ( <strong>anti-slash</strong> ) or <strong><code>/</code></strong> ( <strong>slash</strong> ) characters or a <strong>mix</strong> of them ! Of course, when you use <strong>normal</strong> slashs, the <strong>auto-completion</strong> mechanism with the <strong><code>TAB</code></strong> key, of folders or files, will <strong>not</strong> work.</p>
<p dir="auto">In summary, the lines <strong><code>C:\my folder\My file.txt</code></strong> and <strong><code>C:/my folder/My file.txt</code></strong> are totally <strong>equivalent</strong></p>
<hr />
<p dir="auto">Usually, when creating a file from the <strong>explorer</strong>, you may include any <strong>space</strong> char inside, but not at the <strong>very beginning</strong> or at the <strong>very end</strong> of a file or folder. However, if you’ve opened a <strong>DOS</strong> command <strong>prompt</strong> and use the DOS <strong><code>ren</code></strong> command, you may use the following command :</p>
<pre><code class="language-diff">ren File.txt "   Fi  le  .  txt   " which will rename the "File.txt" file as "   Fi  le  .  txt"
</code></pre>
<p dir="auto">As you can see, <strong>trailing</strong> spaces, after any text, in files or folders, are <strong>not</strong> allowed but you may insert <strong>space</strong> char(s) at any <strong>other</strong> location !</p>
<hr />
<p dir="auto">Given the regex, used in notepad++, to detect links, I tried to identify <strong>all</strong> the characters which need the <strong><code>%nn</code></strong> syntax, like <strong><code>%20</code></strong> to replace any <strong>space</strong> char. After some tries, it happens that only <strong>two</strong> other chars need to be changed, using <strong><code>%nn</code></strong>. So, the complete list is :</p>
<pre><code class="language-diff">    SPACE    %20
    {        %7B
    }        %7D
</code></pre>
<p dir="auto">Now, given all these <strong>preliminary</strong> elements, we can build a <strong>regex</strong> to change any <strong>full</strong> pathmane into a valid <strong>hyperlink</strong> ! I assume <strong>two</strong> hypotheses :</p>
<ul>
<li>
<p dir="auto">Only <strong>one full</strong> pathname per line</p>
</li>
<li>
<p dir="auto">Each pathmane <strong>begins</strong> and <strong>ends</strong> its current line</p>
</li>
</ul>
<hr />
<p dir="auto">So, here is a TEST sheet, which explains what must be <strong>matched</strong> or <em>not</em> matched :</p>
<pre><code class="language-diff">- The regex must MATCH the following lines :

d:\                                        #  FULL pathname WITHOUT quotes
"d:\"                                      #  FULL pathname with QUOTES
d:\x\y\file.docx                           #  FULL pathname with SEVERAL levels of SUBDIRS and a final WORD document
"d:\ä\ö\straße.txt "                       #  FULL pathname with folders with ACCUENTUATED characters and a SPACE char before the ENDING quote
d:/x/y z/file.txt                          #  FULL pathname with a SUBFOLDER containing a SPACE and / SEPARATORS
d:\x\y z\fi le.xlsx                        #  FULL pathname with a SUBFOLDER and the FILENAME containing a SPACE and an EXCEL sheet
C:\                                        #  FULL pathname with a DIFFERENT DRIVE letter
"D:\_DEF\  XY   Z"                         #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and WITHIN its name
"D:\_DEF\  XY   Z\"                        #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and WITHIN its name and a TRAILING anti-slash
"D:/_DEF/  XY   Z"                         #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and WITHIN its name and / SEPARATORS
"D:/_DEF/  XY   Z/"                        #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and WITHIN its name and / SEPARATORS and a TRAINLING slash
"D:\_DEF\  XY   Z\  AB   C  .   txt"       #  FULL pathname with a SUBDIR and the FILE name containing LEADING and MIDDLE spaces
"D:/_DEF/  XY   Z/  AB   C  .   txt"       #  FULL pathname with a SUBDIR and the FILE name containing LEADING and MIDDLE spaces and / SEPARATORS
"D:\_DEF\  XY   Z\RST"                     #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and INSIDE its name and a FILE name WITHOUT extension
"D:/_DEF/  XY   Z/RST"                     #  FULL pathname with a SUBDIR containing SPACES at BEGINNING and INSIDE its name and a FILE name WITHOUT extension
D:\@@\792\!#$%&amp;'()+,-.;@[]^_` {}~€à×.txt   #  FULL pathname with SEVERAL levels of SUBDIRS and a FILE name with ALL symbols between 0X20 and 0x7F plus €à× &gt; 0X7F
D:/@@/792/!#$%&amp;'()+,-.;@[]^_` {}~€à×.txt   #  FULL pathname with SEVERAL levels of SUBDIRS and a FILE name with ALL symbols between 0X20 and 0x7F plus €à× &gt; 0X7F and / SEPARATORS
"d:\x\y\z\abc.txt   "                      #  FULL pathmane with SEVERAL levels of SUBDIRS and TRAILING SPACES after the file EXTENSION

- The regex must NOT match any of the following lines :

d:\                                        #  With a TRAILING space, leading to file:///d:\%20 , identical to file:///d:\
x:                                         #  NO slash NOR anti-slash, after the COLON
-:\                                        #  NO DRIVE letter
Ä:\                                        #  FORBIDDEN drive value 
ä:\                                        #  FORBIDDEN drive value 
\                                          #  NO DRIVE letter and NO COLON
 d:\                                       #  SPACE beginning the FULL pathname
"d:\dir                                    #  TRAILING double quote MISSING
"d:/dir with space                         #  TRAILING double quote MISSING
p:\dir"                                    #  LEADING  double quote missing
d:x\y\file.txt                             #  SLASH or ANTISLASH MISSING after the COLON
this is a test                             #  NO FULL pathname
d:\x\y  \z\abc.txt                         #  Trailing SPACES at END of the Y SUBdirectory
"d:\x\y  \z\abc.txt"                       #  Trailing SPACES at END of the Y SUBdirectory
</code></pre>
<hr />
<p dir="auto">As we suppose that <strong>only one</strong> <em>FULL</em> pathmane must appear on <strong>each</strong> line, this leads to the following <em>INPUT</em> text :</p>
<pre><code class="language-diff">d:\
"d:\"
d:\x\y\file.docx
"d:\ä\ö\straße.txt "
d:/x/y z/file.txt
d:\x\y z\fi le.xlsx
C:\
"D:\_DEF\  XY   Z"
"D:\_DEF\  XY   Z\"
"D:/_DEF/  XY   Z"
"D:/_DEF/  XY   Z/"
"D:\_DEF\  XY   Z\  AB   C  .   txt"
"D:/_DEF/  XY   Z/  AB   C  .   txt"
"D:\_DEF\  XY   Z\RST"
"D:/_DEF/  XY   Z/RST"
D:\@@\792\!#$%&amp;'()+,-.;@[]^_` {}~€à×.txt
D:/@@/792/!#$%&amp;'()+,-.;@[]^_` {}~€à×.txt
"d:\x\y\z\abc.txt   "

d:\ 
x:
-:\
Ä:\
ä:\
\
 d:\
"d:\dir
"d:/dir with space
p:\dir"
d:x\y\file.txt
this is a test
d:\x\y  \z\abc.txt
"d:\x\y  \z\abc.txt"
</code></pre>
<p dir="auto"><strong>Beware</strong> : the second <strong><code>d:\</code></strong> is followed with a <strong>space</strong> char, =&gt; NO match</p>
<hr />
<p dir="auto">We need <strong>two</strong> regexes S/R in order to get <strong>functional</strong> hyperlinks :</p>
<ul>
<li>
<p dir="auto">The <strong>first</strong> S/R <strong><code>A</code></strong> will transform any <strong>FULL</strong> pathname into an <strong>hyperlink</strong>, beginning with the syntax <strong><code>file:///</code></strong></p>
</li>
<li>
<p dir="auto">The <strong>second</strong> S/R <strong><code>B</code></strong> will replace <strong>any</strong> character <strong>SPACE</strong>,<strong><code>{</code></strong> and <strong><code>}</code></strong> with, respectively, the strings <strong><code>%20</code></strong>, <strong><code>%7B</code></strong> and <strong><code>%7D</code></strong>, <strong>only</strong> on lines beginning with the <strong><code>file:///</code></strong> syntax</p>
</li>
</ul>
<p dir="auto">I will use the <strong>free-spacing</strong> mode <strong><code>(?x)</code></strong>, in the <strong>search</strong> regexes, to <strong>better</strong> visualize the different regex parts. So :</p>
<ul>
<li>The S/R <strong>A</strong> is :</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?xi) ^ (")? ( [A-Z] : [/\\] (?: (?: (?![/"\\]) \S | \x20 )* (?![/"\\]) \S [/\\] )* (?: (?: (?![/"\\]) \S | \x20 )* (?![/"\\]) \S )? ) (?(1)\x20*")  $</code></strong></p>
<p dir="auto">REPLACE  <strong><code>file:\x2F\x2F\x2F\2</code></strong></p>
<ul>
<li>The S/R <strong>B</strong> is :</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?x-is) ^ (?!file:/{3}) .+ (*SKIP) (*FAIL) | ( \x20 ) | ( { ) | ( } )</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?1%20)(?2%7B)(?3%7D)</code></strong></p>
<hr />
<p dir="auto">Then, the road map is :</p>
<ul>
<li>
<p dir="auto">Select the zone containing <strong>all</strong> your <strong>full</strong> pathnames list, which will be changed into <strong>hyperlinks</strong></p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
<ul>
<li>
<p dir="auto">Hit the <strong><code>Del</code></strong> key to clear the <strong><code>Find what:</code></strong> zone</p>
</li>
<li>
<p dir="auto">Check the <strong><code>In selection</code></strong> option</p>
</li>
<li>
<p dir="auto">SEARCH <strong><code>(?xi) ^ (")? ( [A-Z] : [/\\] (?: (?: (?![/"\\]) \S | \x20 )* (?![/"\\]) \S [/\\] )* (?: (?: (?![/"\\]) \S | \x20 )* (?![/"\\]) \S )? ) (?(1)\x20*")  $</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE  <strong><code>file:\x2F\x2F\x2F\2</code></strong></p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> search <strong>mode</strong></p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; A message appears : <strong><code>Replace All: 18 occurrences were replaced in selected text</code></strong></p>
<ul>
<li>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>(?x-is) ^ (?!file:/{3}) .+ (*SKIP) (*FAIL) | ( \x20 ) | ( { ) | ( } )</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>(?1%20)(?2%7B)(?3%7D)</code></strong></p>
</li>
<li>
<p dir="auto">Click again on the <strong><code>Replace All</code></strong> button</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; A message appears : <strong><code>Replace All: 69 occurrences were replaced in selected text</code></strong></p>
<p dir="auto">And it gives the <strong>expected</strong> <em>OUTPUT</em> text :</p>
<pre><code class="language-diff">file:///d:\
file:///d:\
file:///d:\x\y\file.docx
file:///d:\ä\ö\straße.txt
file:///d:/x/y%20z/file.txt
file:///d:\x\y%20z\fi%20le.xlsx
file:///C:\
file:///D:\_DEF\%20%20XY%20%20%20Z
file:///D:\_DEF\%20%20XY%20%20%20Z\
file:///D:/_DEF/%20%20XY%20%20%20Z
file:///D:/_DEF/%20%20XY%20%20%20Z/
file:///D:\_DEF\%20%20XY%20%20%20Z\%20%20AB%20%20%20C%20%20.%20%20%20txt
file:///D:/_DEF/%20%20XY%20%20%20Z/%20%20AB%20%20%20C%20%20.%20%20%20txt
file:///D:\_DEF\%20%20XY%20%20%20Z\RST
file:///D:/_DEF/%20%20XY%20%20%20Z/RST
file:///D:\@@\792\!#$%&amp;'()+,-.;@[]^_`%20%7B%7D~€à×.txt
file:///D:/@@/792/!#$%&amp;'()+,-.;@[]^_`%20%7B%7D~€à×.txt
file:///d:\x\y\z\abc.txt

d:\ 
x:
-:\
Ä:\
ä:\
\
 d:\
"d:\dir
"d:/dir with space
p:\dir"
d:x\y\file.txt
this is a test
d:\x\y  \z\abc.txt
"d:\x\y  \z\abc.txt"
</code></pre>
<p dir="auto">IMPORTANT : When you <strong>double</strong> -click on an <strong>hyperlink</strong>, containing an <strong>existing</strong> file, it <strong>automatically</strong> opens in its <strong>default</strong> application =&gt; For instance, any <strong><code>.docx</code></strong> is lauched with Microsoft <strong>Word</strong> and any <strong><code>.xlsx</code></strong> starts with Microsoft <strong>Excel</strong> !</p>
<hr />
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>For the <strong>first</strong> S/R, we can, as well, split over the <strong>search</strong> regex, in <strong>several</strong> lines, like below :</li>
</ul>
<pre><code class="language-diff">(?xi)
^  (")?                                                  #  An OPTIONAL leading quote at BEGINNING of line, stored in Group 1
(                                                        #  START of Group 2
[A-Z]  :  [/\\]                                           #  DRIVE letter, colon and SLASH or ANTI-SLASH
(?: (?: (?![/"\\]) \S | \x20 )* (?![/"\\]) \S  [/\\] )*     #  OPTIONAL SUBSEQUENT subfolder(s) chars, ending with a NON-SPACE char, before a SLASH or ANTI-SLASH
(?: (?: (?![/"\\]) \S | \x20 )* (?![/"\\]) \S )?           #  OPTIONAL NON-SPACE or SPACE chars, ending with a NON-SPACE char ( LAST subfolder or FOLE NAME part )
)                                                        #  END of Group 2
(?(1)\x20*")  $                                          #  OPTIONAL SPACES and the ENDING quote ( if LEADING quote at START ), before the END of CURRENT line
</code></pre>
<ul>
<li>Regarding the <strong>second</strong> S/R, we could also have used this other <strong>search</strong> version, for <strong>same</strong> results :</li>
</ul>
<p dir="auto"><strong><code>(?x-is) (?: ^file:/{3} | (?!\A)\G ) .*? \K (?: ( \x20 ) | ( { ) | ( } ) )</code></strong></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> : This method works for <strong>both</strong> <strong><code>ANSI</code></strong> and <strong><code>UTF-8</code></strong> / <strong><code>UTF-8-BOM</code></strong> encodings !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79560</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79560</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 12 Sep 2022 21:52:09 GMT</pubDate></item><item><title><![CDATA[Reply to Converting Windows file names to links on Sun, 04 Sep 2022 23:05:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tho-gru" aria-label="Profile: tho-gru">@<bdi>tho-gru</bdi></a> said in <a href="/post/79525">Converting Windows file names to links</a>:</p>
<blockquote>
<p dir="auto">I want to transform such string into file:///D:/tmp/file.txt using a single regular expression.</p>
</blockquote>
<p dir="auto">Why make your life unnecessarily complicated?  Break it into smaller regex that you can understand, then record a macro which runs each, and just run that multi-regex macro rather than trying to build it all into one.</p>
<p dir="auto">For example, after your initial transformation, you might do something like <code>(("?)file:((?!\x20+("?)file:).)*?)\x20(?!("?)file:)</code> =&gt; <code>$1%20</code> to replace the spaces inside … though it might have to run more than once to catch multiple spaces in the same file URL)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/79543</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/79543</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sun, 04 Sep 2022 23:05:35 GMT</pubDate></item></channel></rss>