Regex count lowercase letters
Description:
Your task is simply to count the total number of lowercase letters in a string.
Examples
LowercaseCountCheck("abc") == 3
LowercaseCountCheck("abcABC123") == 3
LowercaseCountCheck("abcABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"") == 3
LowercaseCountCheck("") == 0
LowercaseCountCheck("ABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"") == 0
LowercaseCountCheck("abcdefghijklmnopqrstuvwxyz") == 26
using System.Text.RegularExpressions; public class Kata
{
public static int LowercaseCountCheck(string s)
{
string pattern = "[a-z]";
Regex regex = new Regex(pattern);
var temp = regex.Matches(s);
return temp.Count;
}
}
[a-z]是匹配小写字母
用了Matches之后,会把每一个符合条件的提取出来
最后用Count计数
Regex count lowercase letters的更多相关文章
- event.preventDefault(); Please enter your name using lowercase letters only.
w 可以用于移动实际项目. 输入 android qq输入法 输入第一个字符“中”后 w PC 点击enter键13 空格键32 w 没有阻挡中午输入. CODE <!DOCTYPE html& ...
- 第六章第二十题(计算一个字符串中字母的个数)(Count the letters in a string) - 编程练习题答案
*6.20(计算一个字符串中字母的个数)编写一个方法,使用下面的方法头计算字符串中的字母个数: public static int countLetters(String s) 编写一个测试程序,提示 ...
- 316. Remove Duplicate Letters (accumulate -> count of the difference elements in a vector)
Given a string which contains only lowercase letters, remove duplicate letters so that every letter ...
- Count the string[HDU3336]
Count the string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 3336 Count the string(KMP的Next数组应用+DP)
Count the string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Boring count(字符串处理)
Boring count Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- hdu----(5056)Boring count(贪心)
Boring count Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDUOJ------3336 Count the string(kmp)
D - Count the string Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- hdu 3336 Count the string KMP+DP优化
Count the string Problem Description It is well known that AekdyCoin is good at string problems as w ...
随机推荐
- WC2016游记
出发的时候,长沙忽然就出了太阳,明媚而和煦. [day0 25] 噫吁嚱,危乎高哉!蜀道之难,难于上青天! 总之本来上午已经准备好9:50的飞机…然后就在一次次的手机查询中变成了5点多…然后也不是直飞 ...
- 设计模式 - Template Method
今天下午主要研究了设计模式中的Template Method(模版方法设计模式). 在Spring中,对各种O/RM进行了封装,比如对Hibernate有HibernateTemplate封装:对JD ...
- Codeforces Round #274 (Div. 2)
A http://codeforces.com/contest/479/problem/A 枚举情况 #include<cstdio> #include<algorithm> ...
- Metasploit Framework命令汇总
一.msfconsole ? 帮助菜单back 从当前环境返回banner 显示一个MSF bannercd 切换目录color 颜色转换connect 连接一个主机exit 退出MSFhelp 帮助 ...
- linux 访问ntfs分区
打开ntfs-3g的下载点http://www.tuxera.com/community/ntfs-3g-download/ ,将最新稳定(当前最新版本为ntfs-3g-2011.1.15)下载到Ce ...
- SQLite中的日期基础
SQLite包含了如下时间/日期函数: datetime().......................产生日期和时间 date()...........................产生日期 t ...
- 如何将控制台程序包装成windows服务
1. 新建一个项目,或者从选择当前解决方案--右键-添加--新建项目 2. 选择(项目类型)Visual C#项目,(模板)Windows 服务,填写要创建的服务名称(修改默认的WindowServi ...
- CSS 外边距(margin)重叠及防止方法
边界重叠是指两个或多个盒子(可能相邻也可能嵌套)的相邻边界(其间没有任何非空内容.补白.边框)重合在一起而形成一个单一边界. 两个或多个块级盒子的垂直相邻边界会重合.结果的边界宽度是相邻边界宽度中最大 ...
- javascript设计模式--备忘录模式(Memento)
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- racle 11g impdp时 报ORA-12899
racle 11g impdp时 报ORA-12899 (2012-07-16 16:42:12) 转载▼ 标签: oracle imp impdp it 分类: oracle技术-开发 源库ZHS1 ...