View Single Post
Old 10-07-2013, 03:57 AM   #5
Adoby
Handy Elephant
Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.
 
Adoby's Avatar
 
Posts: 1,737
Karma: 26785684
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Samsung Galaxy Tab S8 Ultra
The parentheses creates groups. I put in the parentheses so that the main elements in the searched string would get a separate group. I then simply put the separators, what is between the main elements, between the parentheses to make the right things match. Done!

So the first parentheses will match series name, the second will match the series number and the third parentheses will match the actual title. To use the matches later it is possible to refer to them by number. So when replacing the original title with the actual title I replace it with \3.

To solve the problem as specified only the third parentheses was actually needed. I had all three to help me keep track of where I was in the match, and perhaps also to make the expression more generally usable. It could be used to fill in series information before it is used to set the correct title.

I could have used

^.+\s\[.+\]\s(.+)$

Instead, and replaced with \1 to fix the title.

Last edited by Adoby; 10-07-2013 at 04:06 AM. Reason: Grammar fixed some was
Adoby is offline   Reply With Quote