Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 12-31-2009, 07:44 AM   #1
LARdT
The LARdT of E-Books
LARdT began at the beginning.
 
LARdT's Avatar
 
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>
turned into:
Code:
<div class="s5" id="calibre_toc_2">
<h3 class="calibre2">I. PERDIDOS EN EL COSMOS</h3>
With:
Code:
<div class="s5" id="calibre_toc_[0-9]">\n\s*<p class="calibre2">([\(\Ñ\).a-zA-Z0-9\-_\s\c]*)</p>
I can select all the ocurrences in the file but cannot do any replacement as far as the usual notation does not seem to work
LARdT is offline   Reply With Quote
Old 12-31-2009, 08:12 AM   #2
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,978
Karma: 350515
Join Date: Feb 2008
Device: Sony Reader PRS 505
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.
Valloric is offline   Reply With Quote
Old 12-31-2009, 08:24 AM   #3
LARdT
The LARdT of E-Books
LARdT began at the beginning.
 
LARdT's Avatar
 
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.
LARdT is offline   Reply With Quote
Old 12-31-2009, 08:46 AM   #4
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,142
Karma: 4792399
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...
Jellby is offline   Reply With Quote
Old 12-31-2009, 12:16 PM   #5
sircastor
Reader
sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.
 
sircastor's Avatar
 
Posts: 85
Karma: 6124
Join Date: Jul 2009
Device: PRS-505
Quote:
Originally Posted by Valloric View Post
but I'm slightly reluctant since I'll probably be replacing the currently used engine with PCRE.
Excellent. This is the best news I've heard today.
sircastor is offline   Reply With Quote
Old 12-31-2009, 02:57 PM   #6
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,978
Karma: 350515
Join Date: Feb 2008
Device: Sony Reader PRS 505
Quote:
Originally Posted by sircastor View Post
Excellent. This is the best news I've heard today.
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.
Valloric is offline   Reply With Quote
Old 12-31-2009, 05:28 PM   #7
rogue_ronin
Banned
rogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-books
 
Posts: 475
Karma: 796
Join Date: Sep 2008
Location: Honolulu
Device: Nokia 770 (fbreader)
Quote:
Originally Posted by Valloric View Post
I'll probably be replacing the currently used engine with PCRE.
Wa-hoo!

The universe is kind today!

m a r

ps: I'm a NoteTab dork, and it uses PCRE.
rogue_ronin is offline   Reply With Quote
Old 12-31-2009, 08:00 PM   #8
LARdT
The LARdT of E-Books
LARdT began at the beginning.
 
LARdT's Avatar
 
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.
LARdT is offline   Reply With Quote
Old 12-31-2009, 08:36 PM   #9
Valloric
Created Sigil, FlightCrew
Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.Valloric ought to be getting tired of karma fortunes by now.
 
Valloric's Avatar
 
Posts: 1,978
Karma: 350515
Join Date: Feb 2008
Device: Sony Reader PRS 505
Quote:
Originally Posted by LARdT View Post
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
Well the same reasons too. It's more powerful. I just thought maybe you wanted a specific feature from PCRE.

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:
Originally Posted by LARdT View Post
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.
Actually that's me, not Qt. I like the "\#" notation, it comes from sed. I like sed.

When I get around to creating an options screen, I might make it user-selectable.
Valloric is offline   Reply With Quote
Old 01-01-2010, 12:41 AM   #10
LARdT
The LARdT of E-Books
LARdT began at the beginning.
 
LARdT's Avatar
 
Posts: 106
Karma: 46
Join Date: Dec 2009
Device: HANLIN V3ext (Papyre 6.1)
Quote:
Originally Posted by Valloric View Post
Actually that's me, not Qt. I like the "\#" notation, it comes from sed. I like sed. .
Aaah! Gotcha! I knew it in my bones that wasn't very standard

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.
LARdT is offline   Reply With Quote
Old 01-01-2010, 01:55 AM   #11
sircastor
Reader
sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.sircastor got an A in P-Chem.
 
sircastor's Avatar
 
Posts: 85
Karma: 6124
Join Date: Jul 2009
Device: PRS-505
Quote:
Originally Posted by Valloric View Post
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.
When it comes down to it, it was really a matter of me simply being very familiar with PCRE regex, and not really with any other library. It's just a pain when you have to go look up something.

(I just realized that "PCRE regex" is a bit redundant)
sircastor is offline   Reply With Quote
Old 01-01-2010, 05:48 AM   #12
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,142
Karma: 4792399
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by LARdT View Post
Aaah! Gotcha! I knew it in my bones that wasn't very standard
It's used in vim too, and I like vim
Jellby is offline   Reply With Quote
Old 01-04-2010, 07:25 PM   #13
Sabardeyn
Guru
Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.Sabardeyn ought to be getting tired of karma fortunes by now.
 
Sabardeyn's Avatar
 
Posts: 629
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.
Sabardeyn is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 03:51 AM.


MobileRead.com is a privately owned, operated and funded community.