Hi @kiyn, @alan-kilborn and All,
Ah… You right about it, Alan. Sorry, I was concentrating on my example !
So, regarding the general case and to be rigourous, we should use the generic regular expression itself :
SEARCH (?-si:BSR|(?!\A)\G)(?s-i:(?!ESR).)*?\K(?-si:FR)
REPLACE RR
where :
FR = \x20 ( a space char )
RR = %20
BSR = FILE:///
ESR = The end of any link, beginning with file:/// or FILE:/// : for example, \.mp3 or \.com|\.us or simply \.\w{2,}
Notes :
We can replace the (?-si: modifiers, at the beginning of the regex, by the insensitive modifier (?i: only
We can omit the (?s-i: modifiers, in the middle of the regex, and keep only the non-capturing group (?:(?!ESR).)
We can omit the (?-si: modifiers and the non-capturing group, all together, at the end of the regex
So the generic regex can simply be expressed as :
SEARCH (?i:BSR|(?!\A)\G)(?:(?!ESR).)*?\KFR
REPLACE RR
Thus, the functional regex S/R becomes :
SEARCH (?i:FILE:///|(?!\A)\G)(?:(?!\.\w{2,}).)*?\K\x20
REPLACE %20
And from this INPUT text :
file:///D:\Documentation\Musique\Marilyne\Amy Winehouse - Back To Black.com
first Test
Second test file:///D:\Documentation\Musique\Marilyne\Jason Marz|I'm Yours.fr
FILE:///D:\Documentation\Musique\Marilyne\Norah Jones - Toes.us. Third test
Fourth test file:///D:\Documentation\Musique\Marilyne\Scorpions - Still Loving You.gouv fifth and final test
file:///D:\Documentation\Musique\Marilyne\Norah Jones - Wake Me Up.MP3
We get this OUTPUT text :
file:///D:\Documentation\Musique\Marilyne\Amy%20Winehouse%20-%20Back%20To%20Black.com
first Test
Second test file:///D:\Documentation\Musique\Marilyne\Jason%20Marz|I'm%20Yours.fr
FILE:///D:\Documentation\Musique\Marilyne\Norah%20Jones%20-%20Toes.us. Third test
Fourth test file:///D:\Documentation\Musique\Marilyne\Scorpions%20-%20Still%20Loving%20You.gouv fifth and final test
file:///D:\Documentation\Musique\Marilyne\Norah%20Jones%20-%20Wake%20Me%20Up.MP3
BR
guy038