Reputation: 1858
How do I get the locale in the following XML file name in PowerShell?
xx12345(de-de,xxxx.54).xml
Try to find a better solution for the past hour but no luck. Any help would be appreciated.
Upvotes: 0
Views: 185
Reputation: 201852
I would use a regex here unless the filename format is extremely rigid. Here's a regex to extract the culture and locale:
'xx12345(de-de,xxxx.54).xml' -match '\(([^,]+),'
The info you want is in the automatic variable $matches
in capture group 1 e.g.:
$matches[1]
Outputs:
de-de
Upvotes: 1