Quick Search:
 PHP Code: Count capital letters in a string Jump to:  
Category: >> PHP Code >> Count capital letters in a string  

<< lastnext >>

Snippet Name: Count capital letters in a string

Description: Two easy ways to find how many capital letters there are in a string.

Also see:
» Pre-populated List of Countries
» Neatly trim a string to a set number o...
» Search array elements for a substring
» Add a period at the end of a string if...
» Count capital letters in a string
» Search All Words Of A String In mySQL
» Remove Extra Spaces From A String
» Get Query String with Javascript
» Create string by formatting an amount ...
» SEQUENCE: Find sequence MAX value
» Search PL/SQL for a string/ key value
» RegExp: Append first name first letter...
» INSTR (InString)
» SUBSTR (SubString)
» Generate unique strings of random numb...
» String Functions: REVERSE
» String Functions: LENGTH
» String Functions: INSTR
» String Functions: CONCAT
» String Functions: CHAR
» String Functions: INITCAP
» String Functions: LOWER
» String Functions: UPPER
» Date: Find first day of the month
» Find users with deadly privileges
» Sort comma separated string
» String to Date
» Generate random string
» Find all duplicates in a column
» De-Pluralize a String

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

FUNCTION count_capitals($str) {
  RETURN STRLEN(PREG_REPLACE('![^A-Z]+!', '', $str));
// or...
STR_REPLACE(RANGE('A', 'Z'), '', $str, $num_caps);
PRINT "Number of capital letters: $num_caps";

   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org