I have a space delimited list of files names, where spaces in the file names are prefixed by \'\\\'
e.g. \"first\\ file second\\ file\"
How can I get my rege
(\S|(?<=\\) )+
Explanation:
You are looking for either non white-space characters (\S
) or a space preceded by a backslash, multiple times.
All matches will be saved to mach group 1, apply the pattern globally to get all matches in the string.
EDIT
Thinking about it, you would not even need capturing to a sub-group. The match alone will be enough, so this could be a tiny bit more efficient (the ?:
switches to a non-capturing group):
(?:\S|(?<=\\) )+