![]() |
#1 |
Kindle enthusiast
![]() Posts: 1
Karma: 10
Join Date: Mar 2012
Location: Reston, Virginia
Device: Kindle
|
Sigil Wildcards/Regex Find/Replace
Greetings All --
I've browsed through the Sigil manual and a bunch of posts here. Am I correct that the wildcard option in Find/Replace has been removed from Sigil 0.5.3, leaving Regex as the favored alternative? If my deduction isn't right, I'd appreciate someone telling me how to activate the wildcard option. Regards, -- Adman35 |
![]() |
![]() |
![]() |
#2 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,876
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() Yes, (PCRE) REGEX is the preferred method no more old style wild card as * and ? have special meanings in regex, remember to escape these if that is in your find term. \* \? |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 1
Karma: 10
Join Date: Jun 2011
Device: Kindle
|
This is very annoying! Why has it been removed? Why do I now have to spend hours of my life learning how to use regex?
If it aint broke don't fix it! |
![]() |
![]() |
![]() |
#4 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 657
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
|
Because the old way was only any good in BookView or VERY basic searches, wasn't anywhere near powerful enough for use in CodeView, especially for anything more complex than replacing a straight search term.
|
![]() |
![]() |
![]() |
#5 | |
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Hitch |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,876
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Go read this tutorial, https://www.mobileread.com/forums/sho...d.php?t=118569 It took me from REGEX = ![]() ![]() Also, grab yourself a (free) REGEX cheat sheet from http://www.addedbytes.com/cheat-sheets/ NB They also have HTML and CSS cheat sheets ![]() |
|
![]() |
![]() |
![]() |
#7 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 121
Karma: 5070
Join Date: Dec 2010
Device: none
|
Well, instead of using "*" use ".*" and instead of using "?" use ".". Here you are with wildcards. Its just that simple.
|
![]() |
![]() |
![]() |
#8 |
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21
Karma: 15000
Join Date: Feb 2014
Device: iPhone, iPad, Macbook Pro, Mac Pro
|
Though it is daunting at first, learning regex is the best thing you could do as it comes in handy in many situations. Sigil regex is less strict than 'official' regex and requires less strict regex code. An example that I am using right now:
I wanted to find code segments where a calibre-converted epub from a PDF was splitting sentences at every page break from the PDF, and replace it with nothing, i.e., remove the split. All I had to do was find the first example of this in the HTML file in Sigil, and highlight everything from the </p> tag at the end of the split line to the first character of the next word in the sentence, copy it, and paste it in the 'Find:' box: Original: Code:
opportunity to play with the girl, fleetingly and unbeknownst to Phyllis, before what Izzy called “nights out” each evening. Izzy was the only</p> <p class="whitespace"> </p> <p class="calibre1">person who Petra could talk to about magic, although they had to keep it a sworn secret. Izzy loved Petra’s stories about Code:
</p> <p class="whitespace"> </p> <p class="calibre1"> Code:
</p> <p class="whitespace"> </p> <p class="calibre1">([a-z0-9]) [Image violates guidelines for size - MODERATOR] For 'Replace:', I just use ' \1' -- note the leading <space>. This replaces all the HTML code with a space and the found first character: [Image violates guidelines for size - MODERATOR] Whatever text is found within (…) is copied over by \1. So this basically 'unsplits' the line. The search/replace can be repeated with 'Find', 'Replace', 'Replace/Find', or if you're pretty sure this won't do something unexpected to code you'd rather keep, 'Replace All' -- be careful with this. As far as tools to test your regex, first of all Sigil is the best tool you have because it highlights the results immediately. Or you can go to http://regex101.com/ and use their online tool. It is the very best one I found out of the dozens that I tried. It color codes your regex expressions and highlights your errors and tells you what you did wrong when you hover the mouse cursor over the highlighted error. Fantastic. It is my go-to regex tester. I have RegexBuddy and RegexMagic on Windows, and RegExRX and Reggy on OS X, and I never use them because this online tool is so much better. [Image violates guidelines for size - MODERATOR] [Image violates guidelines for size - MODERATOR] Note that Sigil didn't require the '\' escape character for the '/'. The best interactive regex tutorial I found is RegexOne - Learn regular expressions with interactive examples. It guides you through the basics and quizzes you at each step. The best complete tutorial and reference, from the makers of RegexBuddy, is Regular Expression Tutorial. Last edited by Dr. Drib; 08-17-2014 at 06:40 AM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
More fun with regex / wildcards | zelda_pinwheel | Sigil | 28 | 01-06-2013 09:57 AM |
wildcards in search-replace sigil 0.4905? | Capricorn | Sigil | 13 | 01-19-2012 08:22 PM |
RegEx find and replace | iblesq | Sigil | 1 | 01-10-2011 09:26 PM |
REGEX find and replace help please | potestus | Sigil | 13 | 09-18-2010 04:14 PM |
wildcards in sigil | bobcdy | Sigil | 2 | 12-18-2009 10:19 PM |