CharMatcher removeFrom - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for CharMatcher removeFrom method.

This code example shows how to use the following methods:removeFrom
    { 
    } 
 
    public static boolean isBlank(final String str)
    { 
        return CharMatcher.WHITESPACE.removeFrom(Strings.nullToEmpty(str)).length() == 0;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:removeFrom
     * @param constants The list of constants for the {@link Enum} to which you wish to convert. 
     * @return The enum or null, if no enum constant matched the input value. 
     */ 
    public static Enum<?> fromStringFuzzy(String value, Enum<?>[] constants) {
        final String text = CharMatcher.WHITESPACE
            .removeFrom(value)
            .replace('-', '_')
            .replace('.', '_');
        for (Enum<?> constant : constants) {
            if (constant.name().equalsIgnoreCase(text)) {
                return constant;
            } 
        } 
 
        // In some cases there are certain enums that don't follow the same pattern across an enterprise.  So this 
        // means that you have a mix of enums that use toString(), some use @JsonCreator, and some just use the 
        // standard constant name().  This block handles finding the proper enum by toString() 
        for (Enum<?> constant : constants) {
            if (constant.toString().equalsIgnoreCase(value)) {
                return constant;
4
CodeRank
This code example shows how to use the following methods:removeFrom
    check(c).notNull();
  } 
 
  @Test
  public void marshalingOfNested() { 
    check(CharMatcher.WHITESPACE.removeFrom(
        Marshaling.toJson( 
            ImmutableGroupedClasses.NestedOne.builder().build()))).is("{}"); 
  } 
} 
4
CodeRank
This code example shows how to use the following methods:removeFrom, replaceFrom, retainFrom
		Files.copy(file, System.out);
	} 
	 
	@Test
	public void example16(){ 
		System.out.println(CharMatcher.DIGIT.retainFrom("some text 89983 and more"));//返回数字部分内容
		System.out.println(CharMatcher.DIGIT.removeFrom("some text 89983 and more"));//去除数字
		System.out.println(CharMatcher.DIGIT.replaceFrom("some text 89983 and more","#"));//将数字替换为#
	} 
	 
	/** 
	 * 连接 
	 */ 
	@Test
	public void example17(){ 
		int[] numbers = { 1, 2, 3, 4, 5 };
		String numbersAsString = Joiner.on(";").join(Ints.asList(numbers));
		System.out.println(numbersAsString);
		 
		String numbersAsStringDirectly = Ints.join(";", numbers);
4
CodeRank
This code example shows how to use the following methods:removeFrom
    check(substructure).not().isNull();
  } 
 
  @Test
  public void nullableMarshaling() { 
    check(CharMatcher.WHITESPACE.removeFrom(Marshaling.toJson(ImmutableHasNullable.of())))
        .is("{\"in\":null}"); 
    check(Marshaling.fromJson("{}", ImmutableHasNullable.class)).is(ImmutableHasNullable.of()); 
    check(Marshaling.fromJson("{\"in\":1}", ImmutableHasNullable.class)).is(ImmutableHasNullable.of(1)); 
    check(Marshaling.fromJson("{\"def\":\"1\"}", ImmutableHasNullable.class)).is(ImmutableHasNullable.of().withDef("1")); 
  } 
 
  @Test
  public void jsonIgnore() { 
    ImmutableJsonIgnore minimal = ImmutableJsonIgnore.of(1);
    ImmutableJsonIgnore expanded = minimal.withValues(1, 2);
    check(minimal).not().is(expanded);
    check(Marshaling.fromJson(Marshaling.toJson(expanded), JsonIgnore.class)).is(minimal);
  } 
 
3
CodeRank
This code example shows how to use the following methods:removeFrom
   * 
   * @since 1.28 
   */ 
  public static String removeCRLFInjectionChars(String parameter)
  { 
    return CRLF_CHARMATCHER.removeFrom(parameter);
  } 
 
  /** 
   * Method description 
   * 
   * 
   * @param uri 
   * 
   * @return 
   * @since 1.10 
   */ 
  public static String removeMatrixParameter(String uri)
  { 
    int index = uri.indexOf(';');
2
CodeRank
removeFrom Method Overview
Returns a string containing all non-matching characters of a character sequence, in order.
See Code Examples for other Guava CharMatcher Methods: