java - Finding uppercase characters in a user's string and counting them -


i wanted uppercase characters in string , there count

package test;  import java.util.scanner; import java.util.regex.matcher; import java.util.regex.pattern;  public class case_test {     public static void main(string agrs[]) {          string str1 = "", regx;         regx = "[a-z]+";         scanner sc = new scanner(system.in);         pattern pattern = pattern.compile(regx);         matcher matcher = pattern.matcher(str1);         int count = 0;          system.out.println("enter sentence");         str1 = sc.nextline();          while (matcher.find())             system.out.println(str1.substring(matcher.start(), matcher.end())                     + "*");          count++;     } } 

i wanted uppercase characters in string , amount.

you can use string intersection (intersection of 2 strings in java) using originalstring & originalstring.touppercase().


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -