regexnotepad++textpadfind-replace

In Textpad how to replace space in only part of a string


I have several html files (source code) which contain lots of text and include the code of many reports files linked to.

I need to replace every space ( ) in the filenames by the undescore sign (_). This replace must not affect the rest of the text.

The links all follow the same folder structure, but the filenames are all very different except their extension (.pdf)

For example, I have:

Please find the presentations: 
href="/Portals/12/Documents/GE-Project/Amalty-WS/Joanna_POT Pb paint health econ env_RUS.pdf">Presentation 1

I need:

Please find the presentations: 
href="/Portals/12/Documents/GE-Project/Amalty-WS/Joanna_POT_Pb_paint_health_econ_env_RUS.pdf">Presentation 1

In Windows, using TEXTPAD, I have tried find/replace using regex (/Amalty-WS/[a-z,A-Z,0-9,_, ,]*\.pdf) but can't figure out how to replace only the spaces.


Solution

  • You can use

    (?:\G(?!^)|/Amalty-WS/)[^"\s]*\K\s(?=[^"]*")
    

    Replace with _.

    See the regex demo.

    Details: