Parsing pageranges
| From: | George Pitcher | Date: | Tue, 29 Jun 2004 11:51:12 +0000 |
| Subject: | Parsing pageranges | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-24077@lists.php.net to get a copy of this message | ||
Hi,
I have several systems running which gather, store and process bibliographic
data. I have treated pageranges on the basis of two fields per range - start
and end, with supplemantary ranges available as well.
I've never had to deal with more than 3 ranges in a reference: chapter,
references and notes. Now, a client has asked for 6 ranges. I could
futureproof this by putting 10 ranges in but I got to thinking about how
Pagemaker used to handle prining (and how Micro$oft do now) where I can note
a range as (example) 1-4,6,8-10.
I need to be able to parse this type of string so that I can identify the
number of pages being referenced.
I also need to ensure that the user hasn't entered a mixed range such as
xiii-5 (I know that the second part of that is 1-5 but I don't know what the
highest roman numeral was). I do know how to handle the roman calculations,
so that's a side issue.
I'm guessing that regex is the way to go, but whenever I'm confronted with
it, I look for a chinese interpreter.
Any suggestions?
George in Oxford