tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Google Guava > Basic > Char Matcher OR

Char Matcher OR 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using CharMatcher.or() API. It returns a char matcher that matches either of the given char matchers.

File Name  :  
com/bethecoder/tutorials/guava/base_tests/CharMatcherOrTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.guava.base_tests;

import com.google.common.base.CharMatcher;

public class CharMatcherOrTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    System.out.println(CharMatcher.DIGIT.or(CharMatcher.JAVA_LETTER).apply('A'));
    System.out.println(CharMatcher.DIGIT.or(CharMatcher.JAVA_LETTER).apply('b'));
    System.out.println(CharMatcher.DIGIT.or(CharMatcher.JAVA_LETTER).apply('1'));
    System.out.println(CharMatcher.DIGIT.or(CharMatcher.JAVA_LETTER).apply('9'));
    System.out.println(CharMatcher.DIGIT.or(CharMatcher.JAVA_LETTER).apply('#'));
    System.out.println(CharMatcher.DIGIT.or(CharMatcher.JAVA_LETTER).apply('$'));
  }

}
   

It gives the following output,
true
true
true
true
false
false


                    Print

   



Books Recommendation

 
 
bl  br