Share

Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#.contains()' - 1 code snippet(s) found

 Sample 1. Remove Alien characters i.e removing everything except characters , numbers and special characters.

String removeAlienCharacters(String str){
   String newString = new String();
   String returnString = "";
   if(str.contains("<")){
      String[] str2 = str.split("<");
      str = str2[0];
   }
      
   for(char x: str.toCharArray()){
      if((x >= 48 && x <= 57) || (x>=65 && x <= 90) || (x >= 97 && x<= 122) || x=='.'){
         returnString += x;
      }
   }
   return returnString.trim();
}

   Like      Feedback     string  .contains()  .split()  string split  string contains  remove characters from string  remove alien characters



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus