Regexp for double backslash

I actually want double backslashes in the path i.e. "c:\folder\subfolder" needs to be "c:\\folder\subfolder\". I am at a loss..... here's what I was doing in the button. Certainly the umphteen time backslashes have been discussed in regular expressions, but I can find no relevant posting. Would someone suggest what I am missing please?

Clipboard COPYNAMES=path REGEXP "(.*)(\\)(.*)#" "\1\\\\\3"

This expression returns something close....just not enough times :slight_smile:

Clipboard COPYNAMES=path REGEXP "(.*)(\\)(.*)" "\1\\\\\3"

The first one doesn't work because it'll go on adding more and more backslashes forever (until Opus decides the regexp has gone mad and stops expanding it).

You need to ensure that a backslash is only doubled if it isn't already next to another backslash, like this:

Clipboard COPYNAMES=path REGEXP "(.*[^\])\\([^\].*)#" "\1\\\\\2"

That doesn't give you quadruple backslashes after the "C:" nor any backslashes at the end of the path, but I'm assuming they were typos. If you wanted those then it can be made to do that as well; just shout.

Thanks ! :slight_smile: