View Single Post
Old 06-24-2014, 06:45 AM   #2
Sabardeyn
Guru
Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.
 
Sabardeyn's Avatar
 
Posts: 644
Karma: 1242364
Join Date: May 2009
Location: The Right Coast
Device: PC (Calibre), Nexus 7 2013 (Moon+ Pro), HTC HD2/Leo (Freda)
Ok, I'm not the best person to be answering because I definitely cannot build the regex expression for you. But lets start the ball rolling with some general Q&A that might inspire others to offer some regex examples.

I think it is possible to perform the regex operation that you want, but it's going to require a complex expression depending on what kind of Lastname situation(s) you want to account for. What I mean is, do you have lastnames that include:
  • hyphenated names (Smith-Johnson)
  • multi-word names (Michelle Van de Camp)
  • empty names (ie, Cher - has no last name)
  • names writen in leetspeak (Thompson = +h0|\/|p50|\|)
Are there any other word boundary issues (finding the beginning/end of a name)? Because things like this will be the major issue in determining the correct expression to use.

Another issue is where in calibre do you plan to use this expression? In Add Books? Or in Edit Metadata? Somewhere else?

Does the ebook source follow a distinct, rigidly enforced pattern? For instance a filename like: Title - Firstname Lastname.Extension. Consistent source material helps during input.



PS: Take a look at the topic Tyranosaurus Regex, including my post (msg #17) where the efforts of others came together in a wonderful regex expression which was particularly efficient. I didn't create it, I just stuck it all together (and I got lucky!).

There also used to be a Regex example topic, but I'm not seeing it ATM.

Last edited by Sabardeyn; 06-24-2014 at 06:47 AM.
Sabardeyn is offline   Reply With Quote