How to remove a costant group delay? I have to subtract, from a signal x[n], its version filtered thorugh an LPF FIR filter, like this:

xf=filter(h_lpf,1,x);
y=x-xf;

How can I remove the group delay introduced by the filter h_lpf into the signal xf?

I know it is equal to $\tau_{grp}=\frac{N-1}{2}$, where N is the number of taps.

In my case N is odd, so $\tau_{grp}$ is an integer.

In this page:

http://it.mathworks.com/help/signal/examples/practical-introduction-to-digital-filtering.html#zmw57dd0e2544

in the section (Compensating for Delay Introduced by Filtering) there's a method, which I here adapt for my case: (note: "x" is the input signal, and D is the group delay):

xf = filter(h_lpf,1,[x zeros(1,D)]);      % Append D zeros to the input data
xf = xf(D+1:end);                         % Shift data to compensate for delay
y=x-xf;

Could anyone explain it to me? Could I use it for my problem?
If the low pass filter has a linear phase response, then the group delay it introduces is indeed constant, and it equals $\tau_g=(N-1)/2$ samples, with $N$ being the number of taps. If $N$ is odd, then the group delay is an integer number of samples, and in this case you just have to shift the output signal $\tau_g$ samples to the left as compared to the original signal:

$$y[n]=x[n]-x_f[n+\tau],\quad \tau\in\mathbb{N}$$

This is exactly what the Matlab code in your question does. Don't forget to make sure that the number of filter taps $N$ is odd!

Alternatively, you could delay the original signal $x[n]$ by the filter's group delay before subtracting from it the filtered signal.