View Single Post
Old 03-21-2010, 01:20 PM   #7
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by rollercoaster View Post
@Starson17
thanks for the regex.. this is great..

can it be modified to ignore brackets around series like -

First last - (Series 1) - title.ext
First last - [Series 1] - title.ext
Yes. [\(\[]? means optional open parentheses or square brackets. Try this: (untested by me)

Code:
^((?P<author>([^\-_0-9]+)(?=\s*-\s*)(?!\s*-\s*[0-9.]+)|\b))(\s*-\s*)?([\(\[]?(?P<series>[^0-9\-]+) (- )?(?P<series_index>[0-9.]+)[\)\]]?\s*-\s*)?(?P<title>.+)

Quote:
and i dont know if it is possible but here it goes, can we use regex such that if author name has a coma it swaps first/last name. like -

First Last - title.ext -> Author name = "First Last"
Last, First - title.ext -> Author name = "First Last" instead of "Last, First"
Last, First M.- title.ext -> Author name = "First M. Last" instead of "Last, First M."
You can't use regex to do this - it has to be done in the code. I've considered writing code to do this (you''ll see a discussion of this in some of my posts), but haven't done it. Some author names have commas (Jr, the IIIrd) so that code could cause problems. I wrote code to swap at the comma to deal with authors who have middle names or middle initials, but I decided this autoswap would complicate things too much. (I'm really, really trying not to ask Kovid to add any more options. He's already added 3 for me. That's enough.)

Last edited by Starson17; 03-21-2010 at 01:25 PM.
Starson17 is offline   Reply With Quote