is character a Word Separator - Android java.lang

Android examples for java.lang:Character

Description

is character a Word Separator

Demo Code

import java.net.MalformedURLException;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static final char[] WORD_SEPARATORS = { '_', '-', '@', '$', '#',
            ' ' };
    public static boolean isWordSeparator(char c) {
        for (int i = 0; i < WORD_SEPARATORS.length; i++) {
            if (WORD_SEPARATORS[i] == c) {
                return true;
            }/*from  ww  w  .j av  a2 s.c o  m*/
        }
        return false;
    }

    public static boolean isWordSeparator(char c, char[] wordSeparators) {
        if (wordSeparators == null) {
            return false;
        }
        for (int i = 0; i < wordSeparators.length; i++) {
            if (wordSeparators[i] == c) {
                return true;
            }
        }
        return false;
    }

}

Related Tutorials