Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 11-19-2022, 08:07 PM   #1
Deina97
Member
Deina97 began at the beginning.
 
Deina97's Avatar
 
Posts: 17
Karma: 10
Join Date: Nov 2014
Device: Samsung Note
Regex replacement group before digit

I'm a bit anal. I like to have all my css rules zero filled, so instead of "calibre1", I like "calibre01". And I know just enough Regex to be dangerous.

When I was just doing the rules starting with "calibre" all was fine, I simply used
Code:
Find:
   calibre([1-9])(\D)

Replace:
   calibre0\1\2
and all was copacetic.

Then I decided to get fancy and additionally find "MsoNormal", so that gave me

Code:
Find:
   (calibre|MsoNormal)([1-9])(\D)
which worked a treat to find what I wanted. The problem came with the replace.

I tried using:
Code:
Replace:
   \10\2\3
That gave me a "IndexError: no such group", because it thought I wanted to insert group \10, instead of \1.

I tried putting a space in "\1 0", but that didn't work because it put a space in my output.

How do I solve this, please?
Deina97 is offline   Reply With Quote
Old 11-19-2022, 10:38 PM   #2
Sarmat89
Evangelist
Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.
 
Posts: 482
Karma: 2267928
Join Date: Nov 2015
Device: none
Try
Code:
\1\x30 ...
Sarmat89 is offline   Reply With Quote
Advert
Old 11-20-2022, 05:01 PM   #3
Deina97
Member
Deina97 began at the beginning.
 
Deina97's Avatar
 
Posts: 17
Karma: 10
Join Date: Nov 2014
Device: Samsung Note
Thank you!

That worked finest kind!



Deina97 is offline   Reply With Quote
Reply

Tags
editor selection, epub, regex, replacement


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
regex function replacement The_book Sigil 5 12-09-2019 09:45 AM
Regex: grabbing <h3><span> tag group meghane_e Editor 8 03-28-2019 04:33 PM
Regex replacement qsipl General Discussions 2 07-01-2014 04:28 PM
regex for character replacement, em-dash questions cybmole Calibre 3 10-18-2010 03:09 PM
RegEx REPLACEMENT: Help needed! LARdT Sigil 12 01-04-2010 07:25 PM


All times are GMT -4. The time now is 05:08 AM.


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