Extract pages
Posted: Thu Jan 21, 2010 6:32 pm
I have a text file, a book where each page is separated by a common line. What RegEx should I use if If I wanted to extract only certain pages.
The common line is, lets say:
--Page xx--
where x stands for page number
A sample file, typically, would be:
...
--Page 11--
some text 11
more text 12
--Page 12--
some text 21
more text 22
--Page 13--
some text 31
more text 32
--Page 14--
some text 41
more text 42
--Page 15--
some text 51
more text 52
--Page 16--
some text 61
more text 62
...
Lets say I would want to extract pages 12, 14, 15 to end up:
--Page 12--
some text 21
more text 22
--Page 14--
some text 41
more text 42
--Page 15--
some text 51
more text 52
What RegEx would to the trick? What would the RegEx look like if I would want all pages except pages 12, 14, 15?
Thanks for any help.
Juergen
The common line is, lets say:
--Page xx--
where x stands for page number
A sample file, typically, would be:
...
--Page 11--
some text 11
more text 12
--Page 12--
some text 21
more text 22
--Page 13--
some text 31
more text 32
--Page 14--
some text 41
more text 42
--Page 15--
some text 51
more text 52
--Page 16--
some text 61
more text 62
...
Lets say I would want to extract pages 12, 14, 15 to end up:
--Page 12--
some text 21
more text 22
--Page 14--
some text 41
more text 42
--Page 15--
some text 51
more text 52
What RegEx would to the trick? What would the RegEx look like if I would want all pages except pages 12, 14, 15?
Thanks for any help.
Juergen