06-12-2015, 11:55 PM | #1 |
New old guy
Posts: 69
Karma: 10
Join Date: Feb 2012
Device: kindle fire
|
Help - Learning to use Regex Functions
Struggling to understand use of Regex Functions capability -- primarily how to introduce function arguments. Maybe if someone can illustrate with an example, I can take it from there.
For instance: If I have a set of lines in an epub document such as: <p>chapter 1</p> <p>chapter 1</p> <p>chapter 1</p> <p>chapter 1</p> and what I want is: <p>chapter 1</p> <p>chapter 2</p> <p>chapter 3</p> <p>chapter 4</p> Using the Increment() Function, what would the Find and Function lines look like? Thanx for your help. |
06-13-2015, 02:59 AM | #2 |
Interested in the matter
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
Search (selected files):
(<p>chapter )\d+ Regex-Function: Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): num=number return match.group(1)+str(num) replace.file_order = 'spine' Replace all. Useful link: http://manual.calibre-ebook.com/function_mode.html Last edited by kovidgoyal; 06-13-2015 at 03:07 AM. |
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Certain Functions of Calibre Not Working? | BasilGrows | Calibre | 1 | 06-08-2012 01:14 AM |
Most often used calibre functions | thearr | Calibre | 17 | 08-07-2011 03:44 PM |
Help with MP3 functions on Kindle 2 | Suzy Kindlefan | General Discussions | 0 | 05-22-2010 11:56 AM |
New functions | poco06 | Calibre | 4 | 05-01-2010 02:39 PM |
Changing Button functions | vadindot | iRex | 3 | 03-26-2009 11:49 AM |