View Single Post
Old 12-25-2012, 06:00 PM   #2
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
You use Regular Expressions. RegExp.

There are a lot of special ways you can match different parts of the title.

Because [ and ] has a special meaning in RegExps you have to "escape" them using a backslash to match them. This will match anything surrounded by []:

\[.*\]

This will match a single digit number:

\d

This will match a number, single digit or multiple digits.

\d+

You group patterns using ( ) so you can reference each matching group by number later. \1, \2 and so on.

In your case you could use this RegExp:

(.*) \[(.*) (\d+)\]

\1 = The part of the title before the [].
\2 = The name of the series.
\3 = The number of the book in the series.
(Not tested...)


There is a lot more to this. Check this thread for an actual example of how to use search and replace using RegExps: https://www.mobileread.com/forums/sho...43#post2242243

Last edited by Adoby; 12-25-2012 at 06:46 PM.
Adoby is offline   Reply With Quote