Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 06-21-2014, 03:23 PM   #1
myki
Zealot
myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.
 
Posts: 126
Karma: 20236
Join Date: May 2014
Device: Kinde PW v1, Kobo H2O, Onyx Boox T68
[Solved] function re()

Greetings,

I found in the forum, the way to replace the last point (".") from the author's firstname, like this :
Code:
{#author_sort_firstname:re([.]$,)}
First : I don't understand how it works, can you explain to me ?
(i believed that it used regex ?? and the [.] is before the $ ??)

Second : I want to do the same, but for all points in the firstname, how to do this with the re() function ?

Thanx in advance for your precious help...

Last edited by myki; 06-23-2014 at 05:33 AM.
myki is offline   Reply With Quote
Old 06-21-2014, 04:08 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,443
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by myki View Post
Greetings,

I found in the forum, the way to replace the last point (".") from the author's firstname, like this :
Code:
{#author_sort_firstname:re([.]$,)}
First : I don't understand how it works, can you explain to me ?
(i believed that it used regex ?? and the [.] is before the $ ??)

Second : I want to do the same, but for all points in the firstname, how to do this with the re() function ?

Thanx in advance for your precious help...
Look at the Quality Check Plugin: Fix has a section for formatting Author initials
theducks is offline   Reply With Quote
Advert
Old 06-21-2014, 04:38 PM   #3
myki
Zealot
myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.
 
Posts: 126
Karma: 20236
Join Date: May 2014
Device: Kinde PW v1, Kobo H2O, Onyx Boox T68
Thanx for your help Theducks.

In fact i am building my pattern for the "save as" option.
I want to add the author's first name without points, without changing anything in my database, that's why i need to use the "re()" function.

But the "quality check" plugin will help me for other things for sure
Thank you !

Edit : the first name doesn't need to be extracted from author_sort, because it is allready stored in my personnal field #author_sort_firstname
myki is offline   Reply With Quote
Old 06-22-2014, 05:36 AM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
That just uses the standard python regex re() module, running the regex "[.]$" and replacing it with "" -- the dot is surrounded by brackets to escape its special meaning as match-any-one-character, but you could do the same with "\.$" and of course, the Dollar sign matches the end-of-line border. So you are matching a dot (not any-character) followed by the end of the field.

A regex to match any dot would be "\." since it doesn't only look for the one right before the end-of-line border as indicated by "$".

In order to better understand regex, you may wish to read a tutorial, like the one here: http://www.regular-expressions.info

Last edited by eschwartz; 06-22-2014 at 05:39 AM.
eschwartz is offline   Reply With Quote
Old 06-23-2014, 05:32 AM   #5
myki
Zealot
myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.
 
Posts: 126
Karma: 20236
Join Date: May 2014
Device: Kinde PW v1, Kobo H2O, Onyx Boox T68
Everything is clear now, thank you very much eschwartz
I only knew the "\" to escape a character, and i believed that the $ was to indicate a field to Calibre, like the $ in an expression like {series:'ifempty($,'{author_sort}')'}.

myki is offline   Reply With Quote
Advert
Old 06-23-2014, 12:09 PM   #6
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Brackets are use to create character classes, like [a-z] for lowercase letters; as such, special characters like dot-match-all have no special meaning within the brackets.

Inside a character class, only \^]- have non-literal meanings.

$ when inside a regex gets passed to the regex instead of being translated by calibre first.

Last edited by eschwartz; 06-23-2014 at 12:18 PM.
eschwartz is offline   Reply With Quote
Old 06-23-2014, 06:11 PM   #7
myki
Zealot
myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.myki can self-interpret dreams as they happen.
 
Posts: 126
Karma: 20236
Join Date: May 2014
Device: Kinde PW v1, Kobo H2O, Onyx Boox T68
I see, [.] is not very "pure" but sometimes we get lost when we use a lot of \ and / so it can be useful to cheat a bit

May be you could help me with my other post, that don't seem to passionate peole lol
It's a post still about regex.
You can find it here : Change case in a regular expression

Anyway, thank you very much for the explanations, it is always better that getting the solution too fast
myki is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mini Search function? AndrewH Kobo Reader 4 12-21-2013 12:20 PM
Find function doug38 Ectaco jetBook 3 03-07-2010 11:51 PM
New MAP function? Wetdogeared Feedback 2 03-03-2010 09:11 AM
Sync function rcuadro Calibre 11 11-29-2008 09:19 AM
Is there a way to improve the look up function ? enzo.sandrolini Bookeen 8 07-26-2008 01:10 PM


All times are GMT -4. The time now is 07:33 AM.


MobileRead.com is a privately owned, operated and funded community.