in reply to substitute with space
An empty result means that your initial regex match is not working as expected, so if you showed us the original string and the initial regex, we'd be able to tell you why it failed.
If your initial regex only had one set of parens, then there is no $2 that results from the match -- you need to use $1 instead. Apart from that, if a string contains "+", then your statement s/\+/\s/g will replace each "+" with a literal "s" -- things like "\s, \d, \b" don't work in the right-hand (replacement) side like they do in the left-hand (match) side (but things like "\n, \t, \r" do).
You want to say s/\+/ /g instead.
P.S.: learn about using code tags by looking at Writeup Formatting Tips. You'll see a link to that page every time you preview a new post. Use it.
|
|---|