I want to pre-process C code, replacing
#include "../../abc/efg/hij.h" with
"hij.h".
I use command
'#include "../../abc/efg/hij.h"' -replace '(#include\s+)(".*\w+\.h")',"$(Split-Path -Leaf `$2)"
To do the replacement. However, no matter how I tried (use single-/double- quote, $(), and other methods), the final string (I did not Set-Content yet, just want to see the result in standard output) is still "../../abc/efg/hij.h".
When I run Split-Path -Leaf "../../abc/efg/hij.h", the result is hij.h, which is correct.
Can some one please tell me why this happens? Thank you very much!