I’m trying to remove the parentheses and characters in between from a filename (ie: turn hello world (1234)
into hello world
). Here’s what I’m doing:
PS D:> Rename-Item $x ($x -replace " (*)","") The regular expression pattern (*) is not valid.
My main confusion is due to the fact that I can filter results based on that same format.
gci | where { $_.BaseName -like "* (*)" }
Works fine, but my other command doesn’t.
Side question (not super important) is it possible to specify that I only want to replace what’s in the parentheses if it’s four integers (no more, no less, and no letters)? ie: I would want to remove “(1234)” but not “(12)” or “(hello)”.
Thanks in advance for your help!
submitted by /u/jerdub1993
[link] [comments]
The post Issues with wildcards and removing characters from a string. appeared first on How to Code .NET.