Re: [PHP] Counting Capital Letters

2007-06-21 Thread tedd

At 12:32 AM +0100 6/21/07, Richard Davey wrote:

Hi,

I've written a short regexp which will *count* how many capital letters
are in a given string (the woefully simple: '/[A-Z]/')

Although it's an English language web site, I'm curious how you'd
count capital letters that span beyond just the standard A-Z.

For example characters such as the Latin capital letter S with Acute.
I'm not interested in covering all possible character sets, but I
don't want to piss-off any Europeans who may register on the site and
want to use one of "their own" capital letters.

Anyone approached this before?

Cheers,

Rich


Rich:

Can't say that I have, but try this off the top of my head:

1. Explode the string into two arrays (array1, array2);

2. Lowercase one array;

3. Use array_dif.

4 Count array_dif.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Counting Capital Letters

2007-06-21 Thread Robin Vickery

On 21/06/07, Richard Davey <[EMAIL PROTECTED]> wrote:

Hi,

I've written a short regexp which will *count* how many capital letters
are in a given string (the woefully simple: '/[A-Z]/')

Although it's an English language web site, I'm curious how you'd
count capital letters that span beyond just the standard A-Z.

For example characters such as the Latin capital letter S with Acute.
I'm not interested in covering all possible character sets, but I
don't want to piss-off any Europeans who may register on the site and
want to use one of "their own" capital letters.

Anyone approached this before?


It'd probably be a good start to use [[:upper:]] rather than [A-Z].
There's also \p{Lu} if you use utf-8 mode which matches utf-8
characters with the uppercase letter property.

-robin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Counting Capital Letters

2007-06-20 Thread Richard Davey
Hi,

I've written a short regexp which will *count* how many capital letters
are in a given string (the woefully simple: '/[A-Z]/')

Although it's an English language web site, I'm curious how you'd
count capital letters that span beyond just the standard A-Z.

For example characters such as the Latin capital letter S with Acute.
I'm not interested in covering all possible character sets, but I
don't want to piss-off any Europeans who may register on the site and
want to use one of "their own" capital letters.

Anyone approached this before?

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.corephp.co.uk

"Never trust a computer you can't throw out of a window"

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php