View Single Post
Old 11-16-2018, 02:13 PM   #808
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,354
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ilovejedd View Post
I'm trying to extract the filename (in Calibre for Windows) of a book.

Caveat, it doesn't want to accept backslash as separator? Help, please.

Code:
{:'sublist(select(formats_paths(),"MOBI"),-1,0,"\\")'}
Clearly the lexical analyser is broken. That doesn't really surprise me, given I used regexps to parse strings.

The problem is that the \" is recognized before the \\. This formulation gets rid of the \" by using a character class to change the backslashes into colons, so the problem goes away.
Code:
{:'sublist(re(select(formats_paths(),"MOBI"), '[\\]', ':'), -1,0,":")'}
This formulation gets rid of the sublist, depending on greedy regular expressions
Code:
{:'re(select(formats_paths(),"MOBI"), '.*[\\]', '')'}
chaley is offline   Reply With Quote