Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 10-07-2023, 06:18 PM   #751
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,725
Karma: 5444398
Join Date: Nov 2009
Device: many
Then something must be broken with Minimal Match. I will look into it.
KevinH is offline   Reply With Quote
Old 10-07-2023, 08:53 PM   #752
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,593
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
In my experience Minimal Match is working. It's just that the ? in an expression has the ability to negate/reverse the Minimal Match Setting (and vice-versa).

Consider the following content:

Code:
<p>This is a para.</p>
<p>This is a para.</p>
<p>This is a para.</p>
<p>This is a para.</p>
<p>This is a para.</p>
With Minimal Match unchecked (greedy) and dotAll checked, the following expression will grab multiple attribute-less paragraphs (as is intended):
Code:
<p>.*</p>
But if you leave the regex settings the same (Minimal Match unchecked and dotAll checked) and change the expression to:
Code:
<p>.*?</p>
It will be NON-greedy and only grab the first attribute-less paragraph. Again; as expected.

But this is where it gets tricky. If you leave the expression the same (<p>.*?</p>) and check Minimal Match, the search will then actually become greedy. If you remove the ? from the expression, and leave Minimal Match checked, the results will be non-greedy again.

Sigil's regex has always worked this way to my knowledge. So you have to be careful combining Minimal Match and ?. I've always used one or the other, but very rarely both both at the same time for that very reason.

In short: Using both Minimal Match and "?" can make an expression greedy.

You can also put my original content on one line and eliminate the dotAll option from the equation.
Code:
<p>This is a para.</p><p>This is a para.</p><p>This is a para.</p><p>This is a para.</p><p>This is a para.</p>

Last edited by DiapDealer; 10-07-2023 at 09:00 PM.
DiapDealer is offline   Reply With Quote
Old 10-07-2023, 09:20 PM   #753
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,725
Karma: 5444398
Join Date: Nov 2009
Device: many
Thanks! That makes sense and saves me from having to dive into the regex search code once again!
KevinH is offline   Reply With Quote
Old 10-07-2023, 09:34 PM   #754
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,593
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
No problem. It's come up from time to time.

Leaving dotall unchecked can muddy these waters too. When working on pretty printed p tag stuff, it can lead people to believe their expression is less greedy than it really is. When in fact '.*' is just stopping at line breaks.
DiapDealer is offline   Reply With Quote
Old 12-25-2023, 05:15 AM   #755
iieeann
Member
iieeann began at the beginning.
 
iieeann's Avatar
 
Posts: 12
Karma: 10
Join Date: Dec 2020
Device: Android
Is it possible to do multiple replacement with Sigil regex?
For example, i want to replace the following:-

qw=er
as=df
zx=cv

I can search them with qw|as|zx
But i don't know how to replace them respectively.

The list for replacement is long, and i need to search & replace them for every book, replacing one by one is too troublesome so i am looking for multiple replacement method. Thanks
iieeann is offline   Reply With Quote
Old 12-25-2023, 06:26 AM   #756
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by iieeann View Post
Is it possible to do multiple replacement with Sigil regex?

[...]

The list for replacement is long, and i need to search & replace them for every book, replacing one by one is too troublesome so i am looking for multiple replacement method. Thanks
That's exactly what "Saved Searches" are used for. It can be found in:
  • Tools > Saved Searches

What you'll want to do is create a "Group", then insert all your Search/Replaces underneath that. That will allow you to run a whole giant list of Search/Replaces in a single button push if you wanted to.

I explained how back in:
Tex2002ans is offline   Reply With Quote
Old 12-25-2023, 07:13 AM   #757
iieeann
Member
iieeann began at the beginning.
 
iieeann's Avatar
 
Posts: 12
Karma: 10
Join Date: Dec 2020
Device: Android
Quote:
Originally Posted by Tex2002ans View Post
That's exactly what "Saved Searches" are used for. It can be found in:
  • Tools > Saved Searches
Thanks, this is a feature that I am looking for also, it really helps a lot.
iieeann is offline   Reply With Quote
Old 12-25-2023, 07:25 AM   #758
iieeann
Member
iieeann began at the beginning.
 
iieeann's Avatar
 
Posts: 12
Karma: 10
Join Date: Dec 2020
Device: Android
Back to saved searches in group, is there a way to disable one or few of the long entries before execution?
iieeann is offline   Reply With Quote
Old 12-25-2023, 07:45 AM   #759
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,725
Karma: 5444398
Join Date: Nov 2009
Device: many
You can create multiple subgroups and only run the subgroups you want in your longer saved search group. Or temporarily delete or drag out the few searches you do not want to use, then don't save any changes at the end.
KevinH is offline   Reply With Quote
Old 12-25-2023, 09:48 AM   #760
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,119
Karma: 18727091
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Quote:
Originally Posted by iieeann View Post
Back to saved searches in group, is there a way to disable one or few of the long entries before execution?
You need to highlight the group title you want to run. Also, a little quirk, if you want to run the same group multiple times you need to select a different line and then reselect the group title.
Turtle91 is offline   Reply With Quote
Old 12-25-2023, 11:47 AM   #761
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,725
Karma: 5444398
Join Date: Nov 2009
Device: many
You can also select any set of contiguous searches and run them.
KevinH is offline   Reply With Quote
Old 02-13-2024, 07:21 PM   #762
Mister L
Groupie
Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Posts: 162
Karma: 91148
Join Date: Jun 2010
Device: Sony 350
I am not sure whether this is possible just with regex, I've found some regex + javascript solutions but I don't know how to do that.

I'm hoping to make some kind of system for inserting a pagebreak marker at pre-determined intervals to make a page-list in books which have no paper equivalent.

My idea is, using regex, count X number of characters (including spaces, but text only, no code), and insert a marker after each set, which I can then turn into a properly numbered and formatted epub3 pagebreak.

So for instance, every 1490-1500 characters, insert the marker <span class="pbk" /> (or whatever).

Ideally, I want to avoid inserting it inside words or inside any html code, but it can go between words or between paragraphs.


Ideal results:

(1498 characters)word <span class="pbk" />next word. OK

(1500 characters)</p><span class="pbk" /><p> OK

(1500 characters)<span class="pbk" /></p><p> OK

(1500 characters)</p><p><span class="pbk" /> OK


Undesirable results:

(1499 characters)<<span class="pbk" />/p><p> AVOID

(1498 characters)wo<span class="pbk" />rd AVOID IF POSSIBLE

If there is no way to exclude mid-word insertions I will figure something out but I definitely want to avoid insertions inside html tags.



I tried:

search
((.){20,25})
replace
\1<span class="pbk" />

Search options:
No regex options selected
Text only

(I was using smaller numbers to make it easier to test), but for some reason it does not exclude the code.


I also tried this, hoping to avoid mid-word insertions:
((\w|\s){20,25}\s|\w+\s|$)

But it seems to select only one word + space, regardless of character count, and it excludes punctuation (including apostrophes).


If this is not possible by regex, is it the kind of thing that could be added as a feature, where the number of characters per "page" could be user-defined?


Alternately, if there is any easier way to make digital-only pagebreaks that I haven't heard about I am all ears.

Thanks in advance if anyone has any ideas.
Mister L is offline   Reply With Quote
Old 02-13-2024, 09:42 PM   #763
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,725
Karma: 5444398
Join Date: Nov 2009
Device: many
There is a Sigil, Plugin called "Regex Function Replace", that should be able to count either characters or words of just text and even set the spans with incremented labels and ids with the right python function block.

That may be the easiest way to do what you want.
KevinH is offline   Reply With Quote
Old 02-14-2024, 03:57 AM   #764
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,599
Karma: 23165369
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Mister L View Post
Thanks in advance if anyone has any ideas.
There's a dedicated tool for this task that you might find helpful. Print Page Approximator for EPUB and EPUB3
(The author is an MR member.)
If you happen to have a Kindle, the Calibre KFX output plugin also supports auto-generated page numbers.
Doitsu is offline   Reply With Quote
Old 02-14-2024, 12:15 PM   #765
Mister L
Groupie
Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.Mister L is the 'tall, dark, handsome stranger' all the fortune-tellers are referring to.
 
Posts: 162
Karma: 91148
Join Date: Jun 2010
Device: Sony 350
Quote:
Originally Posted by KevinH View Post
There is a Sigil, Plugin called "Regex Function Replace", that should be able to count either characters or words of just text and even set the spans with incremented labels and ids with the right python function block.

That may be the easiest way to do what you want.
Quote:
Originally Posted by Doitsu View Post
There's a dedicated tool for this task that you might find helpful. Print Page Approximator for EPUB and EPUB3
(The author is an MR member.)
If you happen to have a Kindle, the Calibre KFX output plugin also supports auto-generated page numbers.
Excellent, thank you so much to both of you, this is far beyond what I was hoping for I will take a look at both of those options.
Mister L is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Examples of Subgroups emonti8384 Lounge 32 02-26-2011 06:00 PM
Accessories Pen examples Gunnerp245 enTourage Archive 15 02-21-2011 03:23 PM
Stylesheet examples? Skitzman69 Sigil 15 09-24-2010 08:24 PM
Examples kafkaesque1978 iRiver Story 1 07-26-2010 03:49 PM
Looking for examples of typos in eBooks Tonycole General Discussions 1 05-05-2010 04:23 AM


All times are GMT -4. The time now is 11:00 AM.


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