View Single Post
Old 01-21-2012, 01:23 PM   #1
kamanza
Zealot
kamanza began at the beginning.
 
Posts: 115
Karma: 10
Join Date: Jan 2011
Device: none
Help with regex needed.

I'm trying to write a regex for adding books that would correctly assign categories to hyphenated
and non-hyphenated author names series & book titles, where hyphens inside the names would not
have spaces around them e.g.:


author name - series name index - book title ;
author-name - series name index - book title;
author-name - series name index - book-title;
author-name - series-name index - book-title;
author-name - book-title;


and any other possible combinations.
So far i've managed to deal with the title & series part:

Code:

(?P<author>[^_-]+) -?\s*(?P<series>[^_0-9]*)(?P<series_index>[0-9]*)\s*-\s+(?P<title>[^_].+) ?


But if there is a hyphen in author-name, everything before the hyphen disappears.
being a newbie, i think i've reached the limit of my abilities for the moment, so help would be very
. much appreciated.


N. B. Just noticed a mistake in series part: the second hyphen in "[^_0-9-]" . Corrected.

Last edited by kamanza; 01-21-2012 at 07:20 PM.
kamanza is offline   Reply With Quote