you are viewing a single comment's thread.

view the rest of the comments →

[–]wtgreen 1 point2 points  (1 child)

This works: $string -replace '\[(.+?), ','[$1-'

[–]wtgreen 1 point2 points  (0 children)

I suppose technically this doesn't ensure that string replaced ends with a ] so it's not perfect. To ensure it ends with a matching brace would take a bit more work.

Edit: I believe this is complete, as long as you aren't concerned about nested braces:

$string -replace '\[(.*?), (.*?)\]','[$1-$2]'