I need to extract the data from a file path that contains the recycle bin with the regular expression.
The path is: D:\$RECYCLE.BIN\SubFolder\Subfolder.
I tried the pattern below, but I cannot extract the path since the dollar sign follows immediately after the back slash character which requires an escape character \.
The code I have is:
$path = 'D:\$RECYCLE.BIN\SubFolder\Subfolder'
I would expect the regex will return the data as variable $path, but it does not. However, if I use [regex]::match($path,"[C-Z]:\\.*").value, I got only D:\.BIN which does not include the whole string.
How can I set the pattern for the match so that I can get the data assigned to the variable $path?
Thank you in advance.
Below code works for me after removing the backtick and replacing the double quotes of the pattern with singles to prevent PowerShell variable expansion.
You must be logged in to reply to this topic.