Created
August 5, 2016 13:58
-
-
Save afzafri/7cc1628d206b82192d1a5fe38afe87eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.text.*; | |
public class regex { | |
public static void main(String args[]) | |
{ | |
Scanner input = new Scanner(System.in); | |
int i,j,n; | |
n = Integer.parseInt(input.next()); | |
String words[] = new String[n]; | |
for(i=0;i<n;i++) | |
{ | |
words[i] = input.next(); | |
} | |
System.out.println(); | |
for(i=0;i<n;i++) | |
{ | |
int alpabett = words[i].replaceAll("[^a-zA-Z]","").length(); | |
int num = words[i].replaceAll("[^0-9]","").length(); | |
int sp1 = words[i].replaceAll("[.*a-zA-Z0-9]","").length(); | |
int sp2 = words[i].replaceAll("[^\\.\\*]","").length(); | |
int specchar = sp1+sp2; | |
System.out.print("\nWord: "+words[i]+"\nAlphabets: "+alpabett+"\nNumbers: "+num+"\nSpecial Characters: "+specchar+"\n"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment