06-04-2011, 09:34 AM | #1 |
Nameless Being
|
Help needed with an expression if possible
G'day,
G'day to all, I found this expression in the forums but need help with adding isbn as well. I just can't get my help around expressions, I've tried for hours and can't get it to work for me and am in need of expert help from those smarter than I. ^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^\]{[()]+\w) The above expression when importing books works a treat to a point for me - I name my files as below - its there ALMOST ... the isbn appears with the title and not in its proper place.. John, P. Doe - Keeping The Piece 01 - Out there in space - 123456789123.epub My title returns = Out there in space - 123456789123 Authors = John, P. Doe Series = Keeping the Piece Series Index = 01 ISB = No match Alternately is there a plugin that can accommodate this for those that are expression handicapped like me Thanking you in advance for your assistance. Regards.. |
06-04-2011, 06:34 PM | #2 |
Nameless Being
|
I got lucky
^(?P<author>[^-]+)(\s*-\s*(\[?(?P<series>[^-0-9]+)\s*(?P<series_index>[0-9.]+)?]?)?)?.*?-\s*(?P<title>[^\]{[()]+\w)\s*-s*(?P<isbn>.+) |
Advert | |
|
06-07-2011, 02:14 AM | #3 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
I don't know if you've alreday read it, but there's a tutorial on regular expressions available over in the conversion section.
|
06-07-2011, 05:19 AM | #4 |
Nameless Being
|
I'm aware of the tut - if I were apt enough to understand it would be great unfortunately not as smart as some
|
06-07-2011, 12:10 PM | #5 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
I get that a lot. If you were to give some more concrete criticism other than "it's just too difficult", I'd try to improve it.
|
Advert | |
|
06-07-2011, 12:43 PM | #6 | |
eBook Junkie
Posts: 1,526
Karma: 1464018
Join Date: May 2010
Location: USA
Device: Kindle Fire 2020, Kindle PW2
|
Quote:
Would it be possible to add some more real life examples to it? Or perhaps some of the more complex examples that power or advanced users are using? I know you add examples but maybe something more complex might be helpful. Or perhaps some sticky post in the forum of more commonly used reg expressions. Just a thought. |
|
06-07-2011, 01:08 PM | #7 |
Well trained by Cats
Posts: 29,799
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
The Original, The Goal. Cookbook
I have been saving (in a Notepad file)., Solutions that worked
The Original -> the goal (sample) Search: pattern and settings (I use Sigil for most body edits.) Replace: the term Pitfalls, warnings and restrictions |
06-07-2011, 06:56 PM | #8 |
Connoisseur
Posts: 75
Karma: 600
Join Date: Jul 2008
Location: Depends Upon the Season.....
Device: Cybook, Sony & ipad
|
I have been adding expressions to a spreadsheet when I have success. Using the Quick Preferences plugin has also helped. Being able to name and clear expressions that do not work has made it easier for me.
I would love to see a sticky dedicated to expression examples that have been tested (similar to the plugin index). I find I am able to figure most things out when I have a very concrete example to follow. For the tutorial (which I have been to several times) I would appreciate some real examples. Perhaps starting with something as simple as Name and Title and demonstrating the different expressions used. Continuing onto the series, removing page numbers and other headers/footers. To give a concrete example: FN LN - Title LN, FN - Tile Title - FN LN LN, FN - [Series #] - Title FN LN (Series #) Title Series Name - Title , Title # - Author Series # - Title - LN _ FN Part of what makes this so challenging (and interesting) it that there seem to be multiple ways to get to the same results. I would be happy to send my spreadsheet to Manichean if it would be of any value to start an examples page. |
06-09-2011, 01:54 AM | #9 |
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
I'll see what I can do about more examples this weekend, I should have some time then. As for a list of commonly used expressions/expressions that worked, I don't have any source material for that, since I always create the regexes I need from scratch taylor-made to the specific problem I'm trying to solve, but if you all post some expressions you'd like to see, I'll try to compile them into a new thread. Send your suggestions via PM or answer in this thread.
|
06-09-2011, 06:43 PM | #10 |
Quack! Quack!
Posts: 92
Karma: 9176
Join Date: Apr 2011
Location: Florida
Device: kindle 3 & sony daily prs950sc
|
I agree there needs to be a sticky where there is a list of expressions that work and can be added to. Reading and working with regular expressions is like trying to learn an alien language. Also the expressions change depending on what language. It appears that calibre uses python regex.
I downloaded regexbuddy 3. which helps you craft them but it seems like calibre just won't accept some stuff that it says is good. Anyway a sticky would be great. because your examples in the manual sad to say suxor I'm going to start a new thread because i have a few more complicated regex questions and i don't want it buried at the end of a thread. cheers. btw thanks for creating such a great program! |
06-10-2011, 01:52 AM | #11 | ||
Wizard
Posts: 3,130
Karma: 91256
Join Date: Feb 2008
Location: Germany
Device: Cybook Gen3
|
Quote:
Quote:
|
||
06-10-2011, 02:16 AM | #12 | |
Nameless Being
|
Quote:
I didn't say "it was too difficult" to criticise you or anyone else - I simply said I was not apt enough to understand it, I'll say it in plainer English - I'm stupid when it comes to any type of coding or understanding code - I'm dumb - not as smart as some - perhaps I'm too thick to grasp the fundamentals - there fore I turn to my piers for assistance - or in this case got lucky seeing the code being used elsewhere" All I wanted to know was how to add isbns at the end - I got lucky by cutting pasting code to see if it worked - I still don't understand how it works or why.. But thank you for the feedback... |
|
06-10-2011, 02:39 AM | #13 | |
Quack! Quack!
Posts: 92
Karma: 9176
Join Date: Apr 2011
Location: Florida
Device: kindle 3 & sony daily prs950sc
|
Quote:
And people that use the word honestly in their wording for example, "because I honestly don't know what to change after your thoughtful input." Imply that they haven't been honest before. So the only thing I can see that you accomplished with you quoting my post was a successful troll. Now as far as the manual. If you wrote the examples in it then you need to go back to the drawing board. There are very few example and most are not used in a way that it would be used in calibre. I know this because I have been through it plus a dozen other sites and forums scouring them for regex that would be useful in calibre. Cheers! Last edited by penguinaka; 06-10-2011 at 02:45 AM. |
|
06-10-2011, 03:03 AM | #14 |
Nameless Being
|
I apologise to those reading this thread if I'd known it was going to be such an issue asking a simple question I would have gone without..
Regards |
06-10-2011, 04:33 AM | #15 |
eBook Junkie
Posts: 1,526
Karma: 1464018
Join Date: May 2010
Location: USA
Device: Kindle Fire 2020, Kindle PW2
|
Never think that, although some discussions may become heated, that just shows how passionate many feel about the subject.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need help with Expression | Logan06 | Library Management | 5 | 05-06-2011 04:09 PM |
Need help with expression | Gurkburken | Conversion | 1 | 03-08-2011 02:20 PM |
Regular expression - Example needed | americhanac | Conversion | 1 | 02-08-2011 03:47 AM |
Regular Expression Help Needed | dloyer4 | Calibre | 1 | 07-25-2010 10:37 PM |