sed -e 's/ *-\{0,1\},\{0,1\} *[Pp][Aa]\{0,1\}[Rr]\{0,1\}[Tt].\{0,1\} *\([0-9]\{1,\}\) *$/ (\1)/'
I'm piping titles through this from an iTunes AppleScript. This should convert any title with a Part designation at the end to a parenthetical format
For instance, Best of Both Worlds, Part 2
becomes Best of Both Worlds (2)
.
The trouble rears its head when a space is omitted between Part
and the digit(s).
- If it's a single digit, it works fine.
Blah part2
becomesBlah (2)
- More than one digit, and the first digit gets cut off:
Blah pt123
becomesBlah (23)
I freely admit that I'm no RegEx expert, but I dug around both in the book "Mastering Regular Expressions" and searched google without luck. Any idea what's going awry here? Thanks!