![]() |
#1 |
Junior Member
![]() 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 |
![]() |
![]() |
![]() |
#2 |
Zealot
![]() 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. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() 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. |
![]() |
![]() |
![]() |
#4 |
Sir Penguin of Edinburgh
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,375
Karma: 23555235
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\] |
![]() |
![]() |
![]() |
#5 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
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 02:24 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Zealot
![]() 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 02:47 PM. Reason: Made regex slighlty more reliable. :-) |
![]() |
![]() |
![]() |
#7 |
Junior Member
![]() 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 |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
What's wrong with this regex? | crutledge | Sigil | 1 | 05-11-2010 01:49 PM |
What a regex is | Worldwalker | Calibre | 20 | 05-10-2010 05:51 AM |
Multiline Regex? | prky | Calibre | 25 | 05-01-2010 09:56 PM |
Help with a regex | A.T.E. | Calibre | 1 | 04-05-2010 07:50 AM |
help with regex expression | daesdaemar | Workshop | 4 | 02-19-2010 07:38 AM |