04-11-2018, 12:27 PM | #1 |
Member
Posts: 13
Karma: 10
Join Date: Jul 2015
Device: Nook Simpletouch
|
How to make ebook-convert use multi-line mode regexp?
I want to use ^ and $ in regular expressions in ebook-convert, but it apparently doesn't operate in multi-line mode.
$ cat > sample.txt abc def ghi <ctrl-d> $ ebook-convert.exe sample.txt sample2.txt --sr1-search "abc" --sr1-replace 'zzz' Conversion options changed from defaults: sr1_replace: u'zzz' sr1_search: u'abc' 1% Converting input to HTML... InputFormatPlugin: TXT Input running on Z:\data\text\sci\physics\thermodynamics\sample.txt Language not specified Creator not specified Building file list... Normalizing filename cases Rewriting HTML links flow is too short, not running heuristics Forcing index.html into XHTML namespace 34% Running transforms on e-book... Merging user specified metadata... Detecting structure... Auto generated TOC with 0 entries. Flattening CSS and remapping font sizes... Source base font size is 12.00000pt Removing fake margins... Cleaning up manifest... Trimming unused files from manifest... Creating TXT Output... 67% Running TXT Output plugin Converting XHTML to TXT... TXT output written to Z:\scratch\sample2.txt Output saved to Z:\scratch\sample2.txt $ cat sample2.txt zzz def ghi $ ebook-convert.exe sample.txt sample2.txt --sr1-search "^abc" --sr1-replace 'zzz' Conversion options changed from defaults: sr1_replace: u'zzz' sr1_search: u'^abc' 1% Converting input to HTML... InputFormatPlugin: TXT Input running on Z:\data\text\sci\physics\thermodynamics\sample.txt Language not specified Creator not specified Building file list... Normalizing filename cases Rewriting HTML links flow is too short, not running heuristics Forcing index.html into XHTML namespace 34% Running transforms on e-book... Merging user specified metadata... Detecting structure... Auto generated TOC with 0 entries. Flattening CSS and remapping font sizes... Source base font size is 12.00000pt Removing fake margins... Cleaning up manifest... Trimming unused files from manifest... Creating TXT Output... 67% Running TXT Output plugin Converting XHTML to TXT... TXT output written to Z:\scratch\sample2.txt Output saved to Z:\scratch\sample2.txt $ cat sample2.txt abc def ghi Same result if I use --sr1-search "^abc" instead of --sr1-search '^abc'. |
04-11-2018, 12:37 PM | #2 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Prefix with (?m)
|
04-11-2018, 03:29 PM | #3 |
Member
Posts: 13
Karma: 10
Join Date: Jul 2015
Device: Nook Simpletouch
|
Where does the ?m go?
$ ebook-convert.exe sample.txt sample2.txt --sr1-search '?m^abc' --sr1-replace 'zzz' ... $ cat sample2.txt =~ abc def (It actually puts the =~ into the output, which makes me suspect the program is somehow dropping a bit of its own pattern-matching source code into the output. This is win64 version 3.21 on Windows 7; I just updated it this morning.) I figured out how to do what I need to do without multi-line mode, so I don't need an answer right now. But this =~ might be a bug. Last edited by Shagbark; 04-11-2018 at 03:33 PM. |
04-11-2018, 10:29 PM | #4 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You are missing the parentheses and this is all documented in the manual https://manual.calibre-ebook.com/reg...reference.html
|
Tags |
ebook-convert, regexp |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Change ebook metadata using filename in command-line mode | hfpop | Calibre | 4 | 02-18-2016 05:35 PM |
Multiple line title with ebook-convert | Dyspeptica | Conversion | 3 | 08-20-2012 09:24 PM |
ebook-convert: change settings from command line | miwie | Calibre | 1 | 11-30-2010 02:05 PM |
Multiple line regexp | janvanmaar | Calibre | 19 | 11-02-2010 01:02 PM |
Command Line Options for ebook-convert | godel10 | Calibre | 14 | 08-08-2009 08:28 AM |