I have some string that read like this one here
Dio - We Rock-Greatest Hits (2CD) (2004)
I use this
NewDirectoryName=${NewDirectoryName%'(" ")'* }
NewDirectoryName=${NewDirectoryName//[^A-Za-z ]/ }
and it gives me this left over :
NewDirectoryName is -> Dio We Rock Greatest Hits Cd
it removes the (2CD)
and (2004)
alltogether leaving me with Cd
.
What puzzles me is if it removes the (2004)
, then why does it turn (2CD)
into Cd
. Why only remove (2
and the )
and why is it changing D
to d
?
How do I get rid of the entire thing to get this:
Dio We Rock Greatest Hits
z
in[^A-za-z ]
a typo? It should be an upper-caseZ
'(" ")'
pattern, but you don't have such in your match. and so you don't match. do${var%%\(*}
to strip everything up to the first(
character.