For the sake of simplicity, let's say that we have input strings with this format:
*text1*|*text2*
so, I want to leave text1 alone, and remove all spaces in text2
This could be easy if we didn't have text1, a simple search and replace like this one would do:
%s/\s//g
but in this context I don't know what to do.
I tried with something like:
%s/\(.*|\S*\).\(.*\)/\1\2/g
which works, but removing only the first character, I mean, this should be run on the same line one time for each offending space.
So, a preferred restriction, is to solve this with only one search and replace. And, although I used vim syntax, use the regex flavor you're most comfortable with to answer, I mean, maybe you need some functionality only offered by Perl.
Edit: My solution for vim:
%s:\(|.*\)\@<=\s::g