By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,948 Members | 1,535 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,948 IT Pros & Developers. It's quick & easy.

How to detect if there is more then one capital letter in a word

P: n/a
How can i detect if there is more then capital letter in a word?

Sep 14 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 14 Sep, 12:03, Moham12345 <m_w_r...@hotmail.comwrote:
How can i detect if there is more then capital letter in a word?
sorry i think i did a typo just above... i was meant to say...

How can i detect more then one capital letter in a word?

Sep 14 '07 #2

P: n/a
On 14 Sep, 12:10, Moham12345 <m_w_r...@hotmail.comwrote:
On 14 Sep, 12:03, Moham12345 <m_w_r...@hotmail.comwrote:
How can i detect if there is more then capital letter in a word?

sorry i think i did a typo just above... i was meant to say...

How can i detect more then one capital letter in a word?
I think you were right the first time!

Sep 14 '07 #3

P: n/a
On 14.09.2007 13:10 Moham12345 wrote:
On 14 Sep, 12:03, Moham12345 <m_w_r...@hotmail.comwrote:
>How can i detect if there is more then capital letter in a word?

sorry i think i did a typo just above... i was meant to say...

How can i detect more then one capital letter in a word?

many possibilities, for example

preg_match_all('/[A-Z]/', $str, $m);
$num_up = count($m[0]);

or

$num_up = strlen($str) - strlen(preg_replace('/[A-Z]/', '', $str));

or

$num_up = levenshtein($str, strtolower($str));
where $str is your string and $num_up is a number of uppercase letters
in it.


--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Sep 14 '07 #4

P: n/a
On Fri, 14 Sep 2007 13:44:04 +0200, gosha bine <st********@gmail.com
wrote:
On 14.09.2007 13:10 Moham12345 wrote:
>On 14 Sep, 12:03, Moham12345 <m_w_r...@hotmail.comwrote:
>>How can i detect if there is more then capital letter in a word?
sorry i think i did a typo just above... i was meant to say...
How can i detect more then one capital letter in a word?


many possibilities, for example

preg_match_all('/[A-Z]/', $str, $m);
$num_up = count($m[0]);

Let's summarize by $num_up = preg_match_all('/[A-Z]/', $str, $m);

--
Rik Wasmus
Sep 14 '07 #5

P: n/a
On 14.09.2007 15:13 Rik Wasmus wrote:
On Fri, 14 Sep 2007 13:44:04 +0200, gosha bine <st********@gmail.com>
wrote:
>On 14.09.2007 13:10 Moham12345 wrote:
>>On 14 Sep, 12:03, Moham12345 <m_w_r...@hotmail.comwrote:
How can i detect if there is more then capital letter in a word?
sorry i think i did a typo just above... i was meant to say...
How can i detect more then one capital letter in a word?


many possibilities, for example

preg_match_all('/[A-Z]/', $str, $m);
$num_up = count($m[0]);


Let's summarize by $num_up = preg_match_all('/[A-Z]/', $str, $m);
Yes. ;) I find it utterly stupid that you can't omit the third param for
the cases like this.
--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Sep 14 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.