Answers for "count specific characters from text"

1

how to count number of words in a string

String name = "Carmen is a fantastic play"; //arbitrary sentence
        
        int numWords = (name.split("\\s+")).length; //split string based on whitespace
                                                //split returns array - find legth of array
        
        System.out.println(numWords);
Posted by: Guest on June-06-2020
0

How to check a string for specific characters?

if '$' in myString:
Posted by: Guest on September-28-2020

Code answers related to "count specific characters from text"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language