08-29-2024, 06:32 PM | #1 |
Junior Member
Posts: 7
Karma: 10
Join Date: Aug 2022
Device: Galaxy Tab A 8.0 (2019)
|
Find/Replace wildcard?
I'm trying to replace this
<head><title>DSF Chapter 3 Chapter 3</title> With this <head><title>Chapter 3</title> And while I could certainly get rid of 'DSF Chapter ' I'm not sure how to get rid of that 3. I'm definitely a newbie to Sigil so please use 'Sigil for dummies' phrases |
08-29-2024, 08:04 PM | #2 |
Sigil Developer
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
|
What you are looking for is called Regular Expression Find and Replace (aka regex).
This mode enable placeholders for specific character classes. Digits are represented by \d, and a following + sign means 1 or more. So set Sigil's Find and Replace Mode to Regex. Try using something like the following in the Find Field: DSF Chapter \d+ Before making any big Find Replace changes, I would make a Checkpoint just in case a big find and replace does not work the way you expect. Sigil also has a DryRun Find and Replace command that will show you all the Find and Replaces done in context but not actually perform them, so you can test your regex expressions first. Last edited by KevinH; 08-29-2024 at 08:10 PM. |
08-29-2024, 08:16 PM | #3 |
A Hairy Wizard
Posts: 3,220
Karma: 19000635
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Try:
Find: <title>.*?Chapter\s*(\d*?)\s*.*?</title> Replace: <title>Chapter \1</title> <title> & </title> are just the bounding tags .*? is any number (or none) of any characters \s* is any number (or none) spaces (\d+?) is 1 or more numerical digits and it remembers what it finds The Replace simply inserts the remembered digits into the phrase using the \1. There are some good regex tutorials that will really help when editing code. It doesn't take long to get the basics....it does take forever to become a master... I'm definitely not there yet! Make sure you focus on the PCRE flavor of Regex...that is what Sigil uses. Cheers, |
08-29-2024, 09:00 PM | #4 | |
Junior Member
Posts: 7
Karma: 10
Join Date: Aug 2022
Device: Galaxy Tab A 8.0 (2019)
|
Quote:
|
|
08-29-2024, 09:01 PM | #5 | |
Junior Member
Posts: 7
Karma: 10
Join Date: Aug 2022
Device: Galaxy Tab A 8.0 (2019)
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find/Replace ? | Otter | Calibre | 2 | 10-08-2012 09:48 PM |
Find Replace | unrulyguides | Sigil | 5 | 02-17-2012 09:38 PM |
Find/Replace Won't Find | Rand Brittain | Sigil | 7 | 09-24-2011 05:35 AM |
Find and replace string with wildcard | jhempel24 | Sigil | 15 | 11-12-2010 02:50 PM |
Using Find/Replace with BD | Otter | Sony Reader | 7 | 02-28-2009 02:49 PM |