Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 09-12-2024, 12:07 AM   #1
Chang
Connoisseur
Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 92
Karma: 50000
Join Date: Oct 2009
Device: none
Regex problem with brackets and returning a value from memory

I was doing a page list for my accessible EPUB 3 ebook according to these instructions (https://gold-chartreuse-795z.squares...ng-a-page-list). In one part there is Regex used:

Quote:
Create the correct code for the page breaks. This RegEx string works in oXygen XML editor:
<span class="com-rorohiko-pagestaker-style">(\d+?)</span>
<span epub:type="pagebreak" role="doc-pagebreak" id="page$1" aria-label=" Page $1\. " />
I tried this Regex find and replace search in Sigil and it doesn't seem to work. When I use this same Regex string in Sigil's Regex search, all I get is this:
Quote:
<span epub:type="pagebreak" role="doc-pagebreak" id="page$1" aria-label=" Page $1\. " />
Seems that in Sigil nothing is saved in memory when using brackets. Is there some other way to do this in Sigil? I know in the instructions Sigil is not used for this part but I would like to know why this regex string is not working in Sigil.
Chang is offline   Reply With Quote
Old 09-12-2024, 12:18 AM   #2
Chang
Connoisseur
Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!Chang is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 92
Karma: 50000
Join Date: Oct 2009
Device: none
I just found a solution for my problem and it seems that I'm not able to delete my post anymore.

Instead of $1 I need to use \1 in Sigil to return the value from the memory.

Sorry for posting too hastingly!
Chang is offline   Reply With Quote
Advert
Old 09-12-2024, 01:08 AM   #3
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 40,631
Karma: 157444382
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
You may want to practice RegEx on RegEx 101. Use the PCRE2 flavour of RegEx for Sigil practice. The $1 suggests an ECMAscript/Javascript flavour of RegEx.
DNSB is offline   Reply With Quote
Old 09-13-2024, 03:00 AM   #4
Capricorn
Belgian Pommes Frites
Capricorn will become famous soon enoughCapricorn will become famous soon enoughCapricorn will become famous soon enoughCapricorn will become famous soon enoughCapricorn will become famous soon enoughCapricorn will become famous soon enough
 
Posts: 116
Karma: 532
Join Date: Jan 2012
Device: Pocketbook Touch HD
Hmmmm.....I am confused now. I did a little test:
I put this regex into the regex101 machine, using PCRE2: <span>([^<>]*)</span>
Regex101 then tells me there is a mistake and I need to change it to:
<span>([^<>]*)<\/span> notice the backslash in the closing span

However, when I use <span>([^<>]*)</span> - without the backslash, in Sigil v2.3.1 (running on win11 pro, build 22631.4169), it works perfectly. Hence, my question: Is the regex of Sigil a variant of PCRE2 or...?
As I am not an expert on regex, but still like to use it, I am trying to understand what is going on.

And on this page https://sigil-ebook.com/sigil/ it says it uses PCRE

And when I use python on regex101 instead of PCRE or PCRE2, it does not need a backslash either.

Hmm.....yes, definitely confusing............

Last edited by Capricorn; 09-13-2024 at 03:27 AM.
Capricorn is offline   Reply With Quote
Old 09-13-2024, 07:16 AM   #5
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,454
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
the backslash is the 'Escape' character
That just says take this literally.
[ ] is normally a Set
\[ \] is text enclosed in square brackets
theducks is offline   Reply With Quote
Advert
Old 09-13-2024, 07:25 AM   #6
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: 28,045
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Sigil is definitely not using any variant of pcre2.

I know of no special meaning for the forward slash in pcre2. I've never needed to escape it. If there's an issue, it would seem to me it is with Regex101 and not Sigil, PCRE2, or Python. It certainly won't hurt to escape them, but it seems a waste of time.

NOTE: the only pcre flavors I see on regex101 seem to be php specific. Am I missing something? Forward slashes would definitely need special treatment if used in php.

My guess is that regex101 being a regex analyzer served by a webserver; the forward slash would most definitely need to be escaped. But to my knowledge, that requirement is not inherent to pcre2 itself.

EDIT: Regex101's PCRE/PCRE2 flavors definitely seem to be predicated on the notion that they're going to be used in PHP. That's a mistake in my opinion, but the extra escapes won't cause any harm if you include them.

Last edited by DiapDealer; 09-13-2024 at 09:22 AM.
DiapDealer is offline   Reply With Quote
Old 09-13-2024, 01:10 PM   #7
Capricorn
Belgian Pommes Frites
Capricorn will become famous soon enoughCapricorn will become famous soon enoughCapricorn will become famous soon enoughCapricorn will become famous soon enoughCapricorn will become famous soon enoughCapricorn will become famous soon enough
 
Posts: 116
Karma: 532
Join Date: Jan 2012
Device: Pocketbook Touch HD
Good to know that the problem seems to lie with the regex101 engine, and not sigil. So, no need to adapt any of my regexes. Cool.
Thank you.
Capricorn is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex for title including brackets iamagloworm Library Management 1 05-17-2022 10:29 AM
Problem returning to original page after searching in book alirob Kobo Reader 2 08-19-2013 01:20 AM
Problem returning book with ADE amward General Discussions 15 04-03-2013 01:39 AM
Square brackets in filename breaking Calibre Regex? ccsrsj Library Management 2 06-02-2012 08:38 AM
PRS-505 Returning a Sony PRS-505 Problem :( forkyfork Sony Reader 5 02-12-2011 10:55 PM


All times are GMT -4. The time now is 01:28 PM.


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