09-24-2010, 01:29 AM | #46 | ||
Enthusiast
Posts: 31
Karma: 12
Join Date: Mar 2010
Device: Kindle 2, Kindle 3
|
Quote:
Code:
(?P<author>((?!\s-\s).)+)\s-\s(?:(?P<series>.+)\s(?P<series_index>\d+)\s-\s)?(?P<title>[^(]+)(?:\(.*\))? Quote:
Code:
(?P<author>((?!\s-\s).)+)\s-\s(?:(?:\[\s*)?(?P<series>.+)\s(?P<series_index>\d+)(?:\s*\])?\s-\s)?(?P<title>[^(]+)(?:\(.*\))? Last edited by megachirops; 09-24-2010 at 01:44 AM. |
||
09-24-2010, 05:31 AM | #47 |
Junior Member
Posts: 2
Karma: 10
Join Date: Sep 2010
Device: nook
|
Thanks for the help, I will study it a bit before I ask next question and most files don't have [ ] I removed them for consistancy sake.
Calibreuser |
Advert | |
|
09-24-2010, 11:47 AM | #48 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Just finished another rather large edit- it actually took me longer than originally writing the post.
Concerning the features discussed, I think it's getting to the point that relevant stuff is included. As I stated in the first paragraphs, I want this to be an introduction explaining some basic concepts. With that in mind, is there still something missing? Also, i've shuffled some stuff around to hopefully make more sense for someone new to regular expressions and cleaned up formatting. |
09-24-2010, 01:23 PM | #49 |
creator of calibre
Posts: 44,563
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@Manichean: Drop me a PM when you think the tutorial is ready to be included in the User Manual (if that is including it in the User Manual is ok with you)
|
09-24-2010, 01:28 PM | #50 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
|
Advert | |
|
09-24-2010, 03:44 PM | #51 | |
Wizard
Posts: 3,455
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
Quote:
As for missing features, there is only one thing that might be useful in the new Bulk editing of metadata, in the experimantal Search and Replace. All groups in parenthesis can be referenced in the replace field by using escape sequences \1 \2 ... They can and also be referenced this way in search field, I just can't think of situation when *that* would be used in Calibre. An example. You have set authors field in Calibre to FirstName LastName and you have all metadata for authors_sort in LastName, FirstName and you want to change it to FirstName LastName In the new Search and Replace dialog, you select Search field author_sort, you search for "([^,]*), (.*)" and the replace string is \2 \1 Now, the author_sort that was London, Jack becomes Jack London. There is another little thing you might want to add. Complicated regexps look intimidating, because the syntax is very condensed. But writing regexps is not that difficult if you construct them step by step. In other words, writing regexps is much easier than it would seem when you just read them. |
|
09-24-2010, 03:50 PM | #52 | ||||
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Quote:
Quote:
Quote:
Quote:
|
||||
09-24-2010, 03:55 PM | #53 |
Wizard
Posts: 3,455
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
|
09-24-2010, 04:07 PM | #54 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
|
09-26-2010, 08:39 AM | #55 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Added re-referencing groups and the search & replace- feature.
Personally, I consider this iteration of the introduction to be an excellent candidate for a final version. Thus, I'd like to first, of course, thank those who helped me write this, and second, ask those people (and anyone else who wants to) to re-read the post and make sure it's good. |
09-26-2010, 10:05 AM | #56 | |
Wizard
Posts: 3,455
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
Quote:
Thank you very much. I wish, I had such excellent text available when I was starting to learn Regular Expressions. It was not using Calibre, but manipulating texts in various advanced text editors, such as TextPad on Windows or, later, Vim. It took me many, *many* trials and errors(*), and many re-reads of cryptic, very condensed manuals to discover things that you describe. Then I found the book "Mastering Regular expressions" ;-) The book is excellent, but this Introduction is about the maximum that a person that has never used REs before can (and is willing) to digest. Even more important is, that most users will never require more than you describe, even if they do fairly advanced stuff with RE magic. I think you should definitely consider becoming technical writer. Very few people can understand complicated technical issues AND present them in such a clear, concise manner. Knowing what can be left out for your particular audience is perhaps the most difficult thing for technical writer. You have just made Calibre much more useful tool for many people. ---------------------------- (*) yes, I did fail spectacularly many times and I did take notes ;-) |
|
09-26-2010, 10:12 AM | #57 | |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Quote:
|
|
09-26-2010, 10:31 AM | #58 | |
Wizard
Posts: 3,455
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
Quote:
and indeed, the vast majority or authors do have day job. Even Jeffrey Friedl, author of THE book about Regular Expressions did have day job while he was writing the book http://regex.info/ |
|
09-26-2010, 11:21 AM | #59 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
A comment:
Early on in post 1 it starts with "What on earth is a regular expression?" and by the third sentence we're into case, with lots of discussion about case flags in the discussion that follows. This is a logical place to start that discussion in a general discussion of regexps. A general regexp is case sensitive, and it's an important concept, but as Charles posted about Calibre: Quote:
Since this discussion is specific to Calibre, I wonder if it would be worth stating up front where ignore case is turned on by default and where it can be controlled by selecting an option box. Last edited by Starson17; 09-26-2010 at 11:40 AM. |
|
09-26-2010, 11:45 AM | #60 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
You're right, I must have missed that comment. That means, if I'm not mistaken, that the only place case matters is the search & replace, where it can be controlled with a checkbox, yes? If that's the case (*snigger* I love really bad puns...), I think I'll remove at least the discussion of the ignore case- flag. The case discussion in the paragraph you pointed to could then be rephrased to the effect that yes, generally, case matters, but Calibre ignores it except for one instance. I'd like to keep at least that one reference.
|
Tags |
regexp calibre tutorial |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with regular expressions | Manichean | Conversion | 10 | 02-03-2011 03:27 PM |
Custom Regular Expressions for adding book information | bigbot3 | Calibre | 1 | 12-25-2010 07:28 PM |
Help with Regular Expressions | ghostyjack | Workshop | 2 | 01-08-2010 12:04 PM |
Regular Expressions help needed | Phil_C | Workshop | 20 | 10-03-2009 01:14 AM |
BookDesigner v5 and regular expressions | ShineOn | Sony Reader | 11 | 08-25-2008 05:06 PM |