View Single Post
Old 09-22-2014, 11:49 PM   #601
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
You'd need to have them all have some uniform style, or writing the regex could take nearly as long as doing it manually.

We could do it with multiple passes. For instance,

Find:
Code:
(^[^-]+)( - .*)?(: A Novel|other junk endings)?
Replace:
Code:
\1
Should chop off everything including and after a "-" and removes pesky ": A Novel" and other standardized junk endings.

Find:
Code:
(^[^:]+):.*(\[\d\]|, Book \d+)
Replace:
Code:
\1
Removes anything after a ":" but only if it also matches a "[#]" or the string ", Book #" where # is an actual number of any length. Presumably those are always series' of some sort.

These two should cover every example you gave.

EDIT: Combine the two together with (I think)

Code:
(^[^-:]+)(: (A Novel|other junk endings|(.*(\[\d\]|, Book \d+))))?( - .*)?
I hope you don't have any more styles to filter, though, or this may end up becoming monstrous.

Last edited by eschwartz; 09-23-2014 at 12:07 AM.
eschwartz is offline   Reply With Quote