Android Open Source - no-frills-cpu-classic Pattern Replacer Input Filter

From Project

Back to project page no-frills-cpu-classic.


The source code is released under:

Apache License

If you think the Android project no-frills-cpu-classic listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*from w ww  .  j  a  v  a 2 s  .  co m*/
import android.text.InputFilter;
import android.text.Spanned;

 * Replaces text matching the given pattern removing it.
 * @author luca
public class PatternReplacerInputFilter implements InputFilter {
  private String pattern;

  public PatternReplacerInputFilter(String pattern) {
    if (pattern == null || pattern.trim().length() == 0) {
      throw new IllegalArgumentException("Invalid input pattern: " + pattern);
    this.pattern = pattern;

  public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
    return source.subSequence(start, end).toString().replaceAll(pattern, "");

Java Source Code List