php-windows Digest 30 Sep 2004 02:35:48 -0000 Issue 2414
Topics (messages 24665 through 24670):
Re: ereg_replace help wanted
24665 by: Asendorf, John
24666 by: George Pitcher
24667 by: Felipe Gasper
24669 by: trlists.clayst.com
:)
24668 by: ssb.fast.no
How To Connect USB Port Using PHP Script
24670 by: susilo
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Actually, what you need is split() by the sounds of it. Spliting the groups of pages
by ',' would give you an array of either single pages or ranges of pages. From there,
it is just a matter of mathematics to take the pieces of the new array and adding them
together.
-----Original Message-----
From: George Pitcher [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 29, 2004 9:46 AM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] ereg_replace help wanted
Hi,
I don't want to spend a lot of time leaning how to use this function but I
have a problem that I think it can solve.
I have a web form that allows the user to (amongst other things) submit a
pagerange to my database. Using '-' and ',' as separators, I am able to
calculate the number of pages being submitted.
I can handle roman or arabic numerals and a typical range might look like:
'ix-xxvii,21-30,64' and that would usually give me a page count of 30.
The problem is that I think that some of my users are pasting the range in,
rather than re-typing (I don't really want to stop them from pasting) and I
am sure that sometimes the '-' is coming over as something other than a
conventional hyphen.
Can anyone suggest a filter that will handle my hyphens correctly,
regardless of what type of hyphen the user is entering?
MTIA
George in Oxford
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
John,
I think you've missed my point. I'm currently 'exploding' by ',' to give me
sub ranges and then 'exploding' the subtranges by '-' to get the actual
start and end, adding the subtotals up for the page count. The problem is
that I want to be able to replace the different types of '-' that can come
through, without knowing what they might be using.
In short I'm looking to search for any character that is NOT one of the
following:
"0-9 cdilmvx ," and replace it with '-' [chr(45)] (I do an initial strip of
spaces at the beginning of the process).
Cheers
George
> -----Original Message-----
> From: Asendorf, John [mailto:[EMAIL PROTECTED]
> Sent: 29 September 2004 3:43 pm
> To: George Pitcher; [EMAIL PROTECTED]
> Subject: RE: [PHP-WIN] ereg_replace help wanted
>
>
> Actually, what you need is split() by the sounds of it. Spliting
> the groups of pages by ',' would give you an array of either
> single pages or ranges of pages. From there, it is just a matter
> of mathematics to take the pieces of the new array and adding
> them together.
>
> -----Original Message-----
> From: George Pitcher [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 29, 2004 9:46 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] ereg_replace help wanted
>
>
> Hi,
>
> I don't want to spend a lot of time leaning how to use this function but I
> have a problem that I think it can solve.
>
> I have a web form that allows the user to (amongst other things) submit a
> pagerange to my database. Using '-' and ',' as separators, I am able to
> calculate the number of pages being submitted.
>
> I can handle roman or arabic numerals and a typical range might look like:
> 'ix-xxvii,21-30,64' and that would usually give me a page count of 30.
>
> The problem is that I think that some of my users are pasting the
> range in,
> rather than re-typing (I don't really want to stop them from
> pasting) and I
> am sure that sometimes the '-' is coming over as something other than a
> conventional hyphen.
>
> Can anyone suggest a filter that will handle my hyphens correctly,
> regardless of what type of hyphen the user is entering?
>
> MTIA
>
> George in Oxford
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--- End Message ---
--- Begin Message ---
So maybe explode by commas, then explode by "\D" to get ranges?
-Felipe Gasper
Quoth George Pitcher on 9/29/2004 10:52 AM...
John,
I think you've missed my point. I'm currently 'exploding' by ',' to give me
sub ranges and then 'exploding' the subtranges by '-' to get the actual
start and end, adding the subtotals up for the page count. The problem is
that I want to be able to replace the different types of '-' that can come
through, without knowing what they might be using.
In short I'm looking to search for any character that is NOT one of the
following:
"0-9 cdilmvx ," and replace it with '-' [chr(45)] (I do an initial strip of
spaces at the beginning of the process).
Cheers
George
-----Original Message-----
From: Asendorf, John [mailto:[EMAIL PROTECTED]
Sent: 29 September 2004 3:43 pm
To: George Pitcher; [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] ereg_replace help wanted
Actually, what you need is split() by the sounds of it. Spliting
the groups of pages by ',' would give you an array of either
single pages or ranges of pages. From there, it is just a matter
of mathematics to take the pieces of the new array and adding
them together.
-----Original Message-----
From: George Pitcher [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 29, 2004 9:46 AM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] ereg_replace help wanted
Hi,
I don't want to spend a lot of time leaning how to use this function but I
have a problem that I think it can solve.
I have a web form that allows the user to (amongst other things) submit a
pagerange to my database. Using '-' and ',' as separators, I am able to
calculate the number of pages being submitted.
I can handle roman or arabic numerals and a typical range might look like:
'ix-xxvii,21-30,64' and that would usually give me a page count of 30.
The problem is that I think that some of my users are pasting the
range in,
rather than re-typing (I don't really want to stop them from
pasting) and I
am sure that sometimes the '-' is coming over as something other than a
conventional hyphen.
Can anyone suggest a filter that will handle my hyphens correctly,
regardless of what type of hyphen the user is entering?
MTIA
George in Oxford
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Quidquid latine scriptum sit altum viditur.
Si hoc legere scis, nimis eruditionis habes.
Easier web browsing: http://mozilla.org
--- End Message ---
--- Begin Message ---
On 29 Sep 2004 George Pitcher wrote:
> In short I'm looking to search for any character that is NOT one of the
> following:
>
> "0-9 cdilmvx ," and replace it with '-' [chr(45)] (I do an initial strip of
> spaces at the beginning of the process).
Try something like:
$newstring = preg_replace('/[^cdilmvx0-9,]/', '-', $string);
But do you really want an "A" (etc.) to be considered a dash?
--
Tom
--- End Message ---
--- Begin Message ---
I don't bite, weah!
password: 55535
--- End Message ---
--- Begin Message ---
Dear ALL,
I Wanna connect my usb device ( usb flash disk ), does
everybody know about the php script to get data from that device ?
Regards,
Susilo
--- End Message ---