![]() |
#1 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 718
Karma: 1085610
Join Date: Mar 2009
Location: Bristol, England
Device: PRS-T1, 1825PT, Galaxy Tab, One X, TF700T, Aura HD, Nexus 7
|
Can't seem to get regex to work in Sigil
I'm obviously not getting to grips with regex, even after reading what I can find here.
I've imported a HTML file into Sigil that was generated by Word so I've got an absolute mass of "MsoNormal" classes on my <p> tags. The original file was in a very bad state and would have taken far too much time to tidy it up in Word, so I though I'd do it in Sigil with regex. It also turned out that virtually every paragraph had a different style, so I've also got lots of Sigil-generated styles as well for each paragraph, approximately 5,000 of them. There is no way I'm going to go through this line-by-line and remove them one at a time, so the only way I can see to remove them is with regex. So, to my problem. The <p> tag looks like: Code:
<p class="MsoNormal sgc-669"> This is what I put into the Find field: Code:
<p class="MsoNormal sgc-\d\+"> Code:
<p> When I do this though, Sigil tells me it could find no matches. So, either I've made a mistake in my regex, or Sigil is not working properly for me. So can anyone tell me if my regex is wrong and what I need to do to correct it please. |
![]() |
![]() |
![]() |
#2 |
Sigil developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,274
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
Change \+ to just +
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 718
Karma: 1085610
Join Date: Mar 2009
Location: Bristol, England
Device: PRS-T1, 1825PT, Galaxy Tab, One X, TF700T, Aura HD, Nexus 7
|
Brilliant! That works.
Glad to see it's me getting it wrong and not Sigil. Karma to you. |
![]() |
![]() |
![]() |
#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)
|
You'd use \+ when you would want to search for a + character the \ escapes it from it's normal use of meaning multiplier of previous character
|
![]() |
![]() |
![]() |
#5 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 718
Karma: 1085610
Join Date: Mar 2009
Location: Bristol, England
Device: PRS-T1, 1825PT, Galaxy Tab, One X, TF700T, Aura HD, Nexus 7
|
Ahh, thanks for that, that make a bit more sense.
I'm slowly getting to grips with regex, but I will take a bit more time to figure it out. |
![]() |
![]() |
Advert | |
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sigil Wildcards/Regex Find/Replace | Adman35 | Sigil | 7 | 08-16-2014 01:02 PM |
Sigil 0.4.1 : unwanted span added by Sigil | Bertrand | Sigil | 0 | 09-02-2011 05:28 AM |
Sigil 0.3.4 / Sigil 0.4.0 RC1 / Cover in Nook Color | Bertrand | Sigil | 13 | 08-06-2011 04:06 AM |
Sigil 0.3.4 / Problème CSS entre Sigil et iPad | Grivels | Software | 10 | 07-03-2011 09:06 AM |
Sigil and Regex | crutledge | Sigil | 2 | 07-14-2010 04:51 PM |