Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 03-25-2011, 11:45 AM   #1
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
Need help coming up with another regular expression

I'm having trouble coming up with a regular expression that will work for what I need to do in Sigil. I downloaded a regex cheatsheet and have learned to use some very basic regular expressions but it seems like I run into trouble and have to learn something new every time I try something else.

Here's what I'm wanting to do and what I've tried.
The following string is typical of a chapter subtitle and the first paragraph of a book I'm working on. Most chapters are identical to this except for the actual text of the subtitle.

<p class="chaptersubtitle">An Army of Shadows</p>

<p class="para">

I want to be able to search for this string, regardless of what the actual subtitle text is.

I've tried:

<p class="chaptersubtitle">[:print:]</p>

<p class="calibre1">

and

<p class="chaptersubtitle">[:alnum:]</p>

<p class="calibre1">

but these don't seem to work.

Do any of you regular expression gurus have any ideas?

Any assistance would be greatly appreciated.

Thanks.

- Byron
bfollowell is offline   Reply With Quote
Old 03-25-2011, 11:55 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,003
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by bfollowell View Post
I'm having trouble coming up with a regular expression that will work for what I need to do in Sigil. I downloaded a regex cheatsheet and have learned to use some very basic regular expressions but it seems like I run into trouble and have to learn something new every time I try something else.

Here's what I'm wanting to do and what I've tried.
The following string is typical of a chapter subtitle and the first paragraph of a book I'm working on. Most chapters are identical to this except for the actual text of the subtitle.

<p class="chaptersubtitle">An Army of Shadows</p>

<p class="para">

I want to be able to search for this string, regardless of what the actual subtitle text is.

I've tried:

<p class="chaptersubtitle">[rint:]</p>

<p class="calibre1">

and

<p class="chaptersubtitle">[:alnum:]</p>

<p class="calibre1">

but these don't seem to work.

Do any of you regular expression gurus have any ideas?

Any assistance would be greatly appreciated.

Thanks.

- Byron
Code:
<p class="chaptersubtitle">(.+)</p>\s+<p class="para">
Take care with your replace

Code:
<p class="chaptersubtitle">\1</p> <p class="para">
You need to put back or modify all the Search terms. the \1 places the contents of the first ( ).
(I put it all back in my example)

NB Tidy will take care of the newline between the closeing </p> and the next tag
theducks is offline   Reply With Quote
Advert
Old 03-25-2011, 12:27 PM   #3
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
Thank you very much.

Well, this is certainly getting me closer to what I wanted than what I was trying. Now here's the problem. I only want to select the first chaptersubtitle class paragraph through the very next (first) normal paragraph tag. The expression you gave me selects pretty much ALL text, every single paragraph, character, whatever, through the last <p class="para"> tag.

There may not be a way to have a regular expression do what I'm wanting from the behavior I'm seeing.

Either way, I really appreciate your help. If you have any other ideas, let me know. Are you aware of any decent online resources for learning more about regular expressions?

Thanks again.

- Byron
bfollowell is offline   Reply With Quote
Old 03-25-2011, 01:51 PM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,003
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by bfollowell View Post
Thank you very much.

Well, this is certainly getting me closer to what I wanted than what I was trying. Now here's the problem. I only want to select the first chaptersubtitle class paragraph through the very next (first) normal paragraph tag. The expression you gave me selects pretty much ALL text, every single paragraph, character, whatever, through the last <p class="para"> tag.

There may not be a way to have a regular expression do what I'm wanting from the behavior I'm seeing.

Either way, I really appreciate your help. If you have any other ideas, let me know. Are you aware of any decent online resources for learning more about regular expressions?

Thanks again.

- Byron
Tick the "minimal matching" (Sigils REGEX, non-Greedy) , that should stop it at the first match (but not always )
theducks is offline   Reply With Quote
Old 03-25-2011, 02:09 PM   #5
bfollowell
Fanatic
bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.bfollowell ought to be getting tired of karma fortunes by now.
 
Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
Worked like a charm. Thanks again for your help. Now I need to go add this to my really, really big book of regex info...
bfollowell is offline   Reply With Quote
Advert
Old 03-25-2011, 09:08 PM   #6
st_albert
Guru
st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'st_albert gives new meaning to the word 'superlative.'
 
Posts: 697
Karma: 150000
Join Date: Feb 2010
Device: none
Keep in mind that Sigil's dialect of regex is most like the PERL dialect rather than the POSIX dialect, when you consult your cheat-sheet.

And I, for one, say Gottseidank for that.
st_albert is offline   Reply With Quote
Old 03-26-2011, 04:26 AM   #7
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: 7,546
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Sigil's regex is still Qt's QRegExp, isn't it? Then better refer to the correct doc, which I believe is: http://doc.qt.nokia.com/4.7/qregexp.html
Jellby is offline   Reply With Quote
Old 03-26-2011, 05:25 AM   #8
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,982
Karma: 350515
Join Date: Feb 2008
Device: Kobo Clara HD
Quote:
Originally Posted by Jellby View Post
Sigil's regex is still Qt's QRegExp, isn't it? Then better refer to the correct doc, which I believe is: http://doc.qt.nokia.com/4.7/qregexp.html
Correct.
Valloric is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Azhad Calibre 86 09-27-2011 02:37 PM
Regular Expression Help iKarampa Calibre 13 12-15-2010 07:17 AM
Regular expression help krendk Calibre 4 12-04-2010 04:32 PM
Regular Expression Help smartmart Calibre 5 10-17-2010 05:19 AM
Help with the regular expression Dysonco Calibre 9 03-22-2010 10:45 PM


All times are GMT -4. The time now is 04:58 PM.


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