Java String Remove removeSpecialChars(final String word)

Here you can find the source of removeSpecialChars(final String word)

Description

remove Special Chars

License

Open Source License

Declaration

public static List<String> removeSpecialChars(final String word) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> removeSpecialChars(final String word) {
        // Utility to generate only alpha-numeric tokens from the word.
        if (word.length() == 0)
            return null;
        final List<String> tokenList = new ArrayList<String>();
        String token = "";
        for (int index = 0; index < word.length(); index++) {
            char ch = word.charAt(index);
            if (('a' <= ch && ch <= 'z') || ('0' <= ch && ch <= '9'))
                token += ch;//w  w w  .  j  a  va  2s.  c o m
            else if (token.trim().length() != 0) {
                tokenList.add(token);
                token = "";
            }
        }
        if (token.length() != 0)
            tokenList.add(token);
        return tokenList;
    }
}

Related

  1. removePunctuation(String str)
  2. removePunctuation(String value)
  3. removeRecursive(Object json, String keyToRemove)
  4. removeSomeOne(String words, int count)
  5. removeSpaces(String orig)
  6. removeSpecialCharsForSQLRegExp(String _s)
  7. removeUnusedData(String songData)
  8. removeWaitStatus(String nodeInfo)
  9. removeWhitespace(String inputString)