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

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 04-26-2009, 02:45 PM   #1
Bobthebass
Junior Member
Bobthebass began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jan 2009
Device: Sony PRS-505
Regex help...

I have spent the last couple of hours trying to get my head around regex and attempting (mostly in vain!) to use it.

I have been using Book Designer (and also trying in Notepad++)

There are two things I am trying to Find/Replace.

Page numbers in the format (1 of 251)

- I had partial success in this one and was eventually able to do it in 2 steps, first going to () and then replacing that. Would be nice to do it in one step though.

Secondly, time/date eg [4/24/2009 10:29:37 PM]

-The date bit doesn't change, so I can do a standard replace with that. The time changes in different headers though - how can I replace it?

Any help would be much appreciated.

Bob
Bobthebass is offline   Reply With Quote
Old 04-26-2009, 03:12 PM   #2
notsure
Zealot
notsure has learned how to buy an e-book online
 
Posts: 123
Karma: 76
Join Date: Feb 2009
Device: Sony PRS-505, PRS-350
I can probably help with this but I'm not exactly sure what you want to do once you find the text.

If you give me a clear cut example of the before and after for each I can try to write something up in notepad++.

Cheers.
notsure is offline   Reply With Quote
Old 04-26-2009, 03:16 PM   #3
Bobthebass
Junior Member
Bobthebass began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jan 2009
Device: Sony PRS-505
I just want to replace with a space.

I'm trying to strip these out of the document before converting to epub.

Cheers.
Bobthebass is offline   Reply With Quote
Old 04-26-2009, 03:20 PM   #4
Nate the great
Sir Penguin of Edinburgh
Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.
 
Nate the great's Avatar
 
Posts: 10,566
Karma: 3586209
Join Date: Apr 2007
Location: DC Metro area
Device: Shake a stick plus 1
Both of these are for Book Designer.Here is the one for page numbers:

\([0-9]{0,3} of [0-9]{0,3}\)


And here is the one for the time and date:

\[4/24/2009 [0-9]{1,2}:[0-9]{2}:[0-9]{2} PM\]
Nate the great is offline   Reply With Quote
Old 04-26-2009, 03:22 PM   #5
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,259
Karma: 4801165
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
With vim's regexp, I'd do:

Page numbers in the format (1 of 251): (\d\+ of \d\+)

Secondly, time/date eg [4/24/2009 10:29:37 PM]: \[4\/24\/2009 \d\+:\d\+:\d\+ [AP]M\]

where:

\d\+: one or more digits
\[, \], \/: literal [, ], or /
[AP]: A or P

And from Nate's reply, I guess for BookDesigner:

\([0-9]{1,3} of [0-9]{1,3}\)
\[4/24/2009 [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2} [AP]M\]

Last edited by Jellby; 04-26-2009 at 03:24 PM.
Jellby is offline   Reply With Quote
Old 04-26-2009, 03:29 PM   #6
notsure
Zealot
notsure has learned how to buy an e-book online
 
Posts: 123
Karma: 76
Join Date: Feb 2009
Device: Sony PRS-505, PRS-350
\(\d+ of \d+\)

and

\[\d+\/\d+\/\d+.*\]

That should do it.

Cheers

Last edited by notsure; 04-26-2009 at 03:47 PM. Reason: Made regex slighlty more reliable. :-)
notsure is offline   Reply With Quote
Old 04-26-2009, 04:54 PM   #7
Bobthebass
Junior Member
Bobthebass began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jan 2009
Device: Sony PRS-505
Thanks all for the replies.

All worked, but for some reason BookDesigner would only replace 25 - 30 at a time. I then had to scroll down a bit and then find/replace again.

So in this case it was quicker in Notepad++

But all the same it is really helpful to have the BD examples as it's helped me understand the syntax better.

Cheers,

Bob
Bobthebass 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
What's wrong with this regex? crutledge Sigil 1 05-11-2010 02:49 PM
What a regex is Worldwalker Calibre 20 05-10-2010 06:51 AM
Multiline Regex? prky Calibre 25 05-01-2010 10:56 PM
Help with a regex A.T.E. Calibre 1 04-05-2010 08:50 AM
help with regex expression daesdaemar Workshop 4 02-19-2010 08:38 AM


All times are GMT -4. The time now is 09:48 PM.


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