Given a string:
rsync -r -t -p -o -g -v --progress --delete -l -H /Users/ken/Library/Application\ Support/Sublime\ Text\ 3/Packages /Users/ken/Google\ Drive/__config-GD/ST3
Attempting to find a regex pattern that matches spaces, but excludes escaped spaces.
First attempt to match escaped space (or any character):
\\.
http://regex101.com/r/uL0mP8 successfully matches.
Next, trying to match spaces while excluding escaped spaces:
(?!\\.)
http://regex101.com/r/fK3sW9 does not produce the desired results.
What may be the issue with the code? It is written in javascript.
Thank you
EDIT:
(?<!\\)
http://regex101.com/r/fZ5uP2 works!
I should have utilized Negative Lookbehind...
EDIT2:
var command0 = `rsync -r -t -p -o -g -v --progress --delete -l -H /Users/ken/Library/Application\ Support/Sublime\ Text\ 3/Packages /Users/ken/Google\ Drive/__config-GD/ST3`;
var regex = new RegExp('(?<!\\)\s')
var commandA = command0.split(regex);
Error -
Invalid regular expression: /(?<!\\)\s/: Invalid group
Oops, what is the workaround in JavaScript??
Okay, lookbehinds are not supported in JavaScript. I'm unsure how http://regex101.com can output. Perhaps for PHP or other server-side languages.
EDIT3:
This has been quite challenging. Check out the complete working code I have shared:
shell command to child_process.spawn(command, [args], [options]) node.js