12-31-2009, 07:44 AM | #1 |
The LARdT of E-Books
Posts: 106
Karma: 46
Join Date: Dec 2009
Device: HANLIN V3ext (Papyre 6.1)
|
RegEx REPLACEMENT: Help needed!
Does anyone now which is the notation for the replacement operator?
%1 and $1 do not seem to work I want this: Code:
<div class="s5" id="calibre_toc_2"> <p class="calibre2">I. PERDIDOS EN EL COSMOS</p> Code:
<div class="s5" id="calibre_toc_2"> <h3 class="calibre2">I. PERDIDOS EN EL COSMOS</h3> Code:
<div class="s5" id="calibre_toc_[0-9]">\n\s*<p class="calibre2">([\(\Ñ\).a-zA-Z0-9\-_\s\c]*)</p> |
12-31-2009, 08:12 AM | #2 |
Created Sigil, FlightCrew
Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
|
It's \#.
I really need to write a wiki page for the regex syntax... but I'm slightly reluctant since I'll probably be replacing the currently used engine with PCRE. Anyway, you can see the upstream documentation on the regex engine that Sigil uses here. |
Advert | |
|
12-31-2009, 08:24 AM | #3 |
The LARdT of E-Books
Posts: 106
Karma: 46
Join Date: Dec 2009
Device: HANLIN V3ext (Papyre 6.1)
|
I read the link before and as far as I remember
there is no reference to \# nor replace. ¿could you please use it in the example I'm working on? I cannot make it work EDIT: No need to. I've figured out myself. Odd notation though. Thanks anyway. Last edited by LARdT; 12-31-2009 at 08:48 AM. |
12-31-2009, 08:46 AM | #4 |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
I think it means using \1, \2, etc. instead of %1 or $2...
|
12-31-2009, 12:16 PM | #5 |
Reader
Posts: 85
Karma: 6124
Join Date: Jul 2009
Device: PRS-505
|
|
Advert | |
|
12-31-2009, 02:57 PM | #6 |
Created Sigil, FlightCrew
Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
|
Really? You care that much about the possibility of the internal regex engine switching to PCRE? I'd love to know why.
I mean, I know why I care about it, but I'm interested in why are you so excited about the prospect. Knowing the reason would give me more perspective. |
12-31-2009, 05:28 PM | #7 |
Banned
Posts: 475
Karma: 796
Join Date: Sep 2008
Location: Honolulu
Device: Nokia 770 (fbreader)
|
|
12-31-2009, 08:00 PM | #8 |
The LARdT of E-Books
Posts: 106
Karma: 46
Join Date: Dec 2009
Device: HANLIN V3ext (Papyre 6.1)
|
Well, I suppose you are thinking on development issues but I've consulted the Wiki comparison between RegeX ENGINES and Qt seemed to be the less powerful and flexible:
http://en.wikipedia.org/wiki/Compari...ession_engines Anyway it has done the job perfectly after the initial surprise because of the non-standard (if there is such thing as a standard for RegEx) notation. |
12-31-2009, 08:36 PM | #9 | ||
Created Sigil, FlightCrew
Posts: 1,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
|
Quote:
I'm also fairly sure PCRE will be much faster. I'll have to profile that to be sure, but I have a feeling. Quote:
When I get around to creating an options screen, I might make it user-selectable. |
||
01-01-2010, 12:41 AM | #10 | |
The LARdT of E-Books
Posts: 106
Karma: 46
Join Date: Dec 2009
Device: HANLIN V3ext (Papyre 6.1)
|
Quote:
Now that I've you on the line, lets talk about SIGIL "philosophy": I've been thinking about what you said about the program sticking to the "Editor" tool concept. Let say that the program has now 2 clear edition "layers": - One "high level", user friendly, WYSISWYG related layer. - Other "low level" advanced user, CODE related layer. Perhaps the program will become an original & powerful tool if it develops functionalities in an in-between "layer". For example: beign able to manage a library of personal CSS styles to apply them over existing CSS styles generated by conversion software. |
|
01-01-2010, 01:55 AM | #11 | |
Reader
Posts: 85
Karma: 6124
Join Date: Jul 2009
Device: PRS-505
|
Quote:
(I just realized that "PCRE regex" is a bit redundant) |
|
01-01-2010, 05:48 AM | #12 |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
01-04-2010, 07:25 PM | #13 |
Guru
Posts: 644
Karma: 1242364
Join Date: May 2009
Location: The Right Coast
Device: PC (Calibre), Nexus 7 2013 (Moon+ Pro), HTC HD2/Leo (Freda)
|
just, FYI, their is a link to a regex tutorial for python (but including references to other flavors of regex expressions) under software called REGEX BUDDY. While it is a little steep for the average newbie, someone with programming experience should be able to handle it pretty well.
I cannot remember the exact name of the site, thus the indirect reference. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Chapter detection when only digits - regex needed | Perkin | Calibre | 15 | 09-20-2010 06:25 PM |
What a regex is | Worldwalker | Calibre | 20 | 05-10-2010 05:51 AM |
Regex help needed | gandor62 | Calibre | 2 | 11-04-2009 10:27 AM |
Replacement Battery - Needed? | Halk | Bookeen | 13 | 08-28-2009 04:46 PM |