![]() |
#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 ![]() |
![]() |
![]() |
![]() |
#2 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,010
Karma: 5449552
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; Today at 07:10 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,160
Karma: 18843349
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, |
![]() |
![]() |
![]() |
#4 | |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Aug 2022
Device: Galaxy Tab A 8.0 (2019)
|
Quote:
|
|
![]() |
![]() |
![]() |
#5 | |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Aug 2022
Device: Galaxy Tab A 8.0 (2019)
|
Quote:
|
|
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Find/Replace ? | Otter | Calibre | 2 | 10-08-2012 08:48 PM |
Find Replace | unrulyguides | Sigil | 5 | 02-17-2012 08:38 PM |
Find/Replace Won't Find | Rand Brittain | Sigil | 7 | 09-24-2011 04:35 AM |
Find and replace string with wildcard | jhempel24 | Sigil | 15 | 11-12-2010 01:50 PM |
Using Find/Replace with BD | Otter | Sony Reader | 7 | 02-28-2009 01:49 PM |