Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,924 questions

51,857 answers

573 users

How to extract only words with first-letter lowercase from a string in Java

6 Answers

0 votes
class Program {
    public static void main(String[] args) {
        String s = "java Programming language"; 
        String lcw = "";        
        String[] arr = s.split(" ");    
  
        for (String word : arr) {
            if (Character.isLowerCase(word.charAt(0))) {
                lcw += word + " ";
            }
        }
                 
        lcw = lcw.trim();
        
        System.out.println(lcw);
    }
}



/*
  
run:
                     
java language
   
*/

 



answered Feb 5, 2017 by avibootz
edited Apr 13, 2024 by avibootz
0 votes
class Program {
    public static void main(String[] args) {
        String s = "java Programming language"; 
        
        String[] arr = s.split(" ");    
   
        for (String word : arr) {
            if (Character.isLowerCase(word.charAt(0))) {
                System.out.println(word);
            }
        }
    }
}



/*
  
run:
                     
java
language
   
*/

 



answered Feb 5, 2017 by avibootz
edited Apr 13, 2024 by avibootz
0 votes
import java.util.ArrayList;
  
class program {
    static ArrayList<String> extract_only_words_with_first_letter_lowercase(String s) {
        ArrayList<String> words = new ArrayList<String>();
 
        int start = 0;
        int end;
        while ((end = s.indexOf(" ", start)) != -1) {
            String word = s.substring(start, end);
  
            if (Character.isLowerCase(word.charAt(0))) {
                words.add(word);
            }
            start = end + 1;
        }
      
        if (Character.isLowerCase(s.substring(start).charAt(0))) {
            words.add(s.substring(start));
        }
      
        return new ArrayList<String>(words);
    }
      
    public static void main(String[] args) {
        String s = "Java is a High-level, object-oriented pPogramming language";
      
        ArrayList<String> words = extract_only_words_with_first_letter_lowercase(s);
      
        for (String w : words) {
            System.out.println(w);
        }
    }
}
  
  
  
  
/*
run:
    
is
a
object-oriented
pPogramming
language
    
*/

 



answered Apr 13, 2024 by avibootz
0 votes
import java.util.ArrayList;
  
class program {
    static ArrayList<String> extract_only_words_with_first_letter_lowercase(String s) {
        ArrayList<String> lowercase = new ArrayList<String>();
        String[] words = s.split("\\s+");
  
        for (String word : words) {
            if (Character.isLowerCase(word.charAt(0))) {
                lowercase.add(word);
            }
        }
         
        return new ArrayList<String>(lowercase);
    }
      
    public static void main(String[] args) {
        String s = "Java is a High-level, object-oriented pPogramming language";
      
        ArrayList<String> words = extract_only_words_with_first_letter_lowercase(s);
      
        for (String w : words) {
            System.out.println(w);
        }
    }
}
 
  
  
/*
run:
    
is
a
object-oriented
pPogramming
language
    
*/

 



answered Apr 13, 2024 by avibootz
0 votes
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.ArrayList;
import java.util.List;

public class Main {

    // Function to extract words starting with lowercase
    public static List<String> extractLowercaseWords(String text) {
        List<String> result = new ArrayList<>();
        Matcher m = Pattern.compile("\\b[a-z]\\w*").matcher(text);

        while (m.find()) {
            result.add(m.group());
        }

        return result;
    }

    public static void main(String[] args) {
        String text = "PHP rust JavaScript c C++ java Typescript python";

        List<String> lowercaseWords = extractLowercaseWords(text);

        System.out.println(lowercaseWords);
    }
}



/*
run:

[rust, c, java, python]

*/

 



answered Jan 16 by avibootz
0 votes
import java.util.ArrayList;
import java.util.List;

public class Program {

    // Function to extract words starting with lowercase
    public static List<String> extractLowercaseWords(String text) {
        List<String> result = new ArrayList<>();

        for (String word : text.split("\\s+")) {
            if (!word.isEmpty() && Character.isLowerCase(word.charAt(0))) {
                result.add(word);
            }
        }
        
        return result;
    }

    public static void main(String[] args) {
        String text = "PHP rust JavaScript c C++ java Typescript python";

        List<String> lowercaseWords = extractLowercaseWords(text);

        System.out.println(lowercaseWords);
    }
}


/*
run:

[rust, c, java, python]

*/

 



answered Jan 16 by avibootz

Related questions

...