tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Jodd > Strings > How to remove specified characters from string

How to remove specified characters from string 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to use StringUtil.removeChars() API. It removes the specified characters from the source string.

File Name  :  
com/bethecoder/tutorials/jodd/utils/StringRemoveCharsTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.jodd.utils;

import jodd.util.StringUtil;

public class StringRemoveCharsTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    String str = "cost of pen is $1234 in market";
    String cost = StringUtil.removeChars(str, "abcdefghijklmnopqrst $");
    System.out.println(cost);
    
    str = "cost of pencil is $48 in market";
    cost = StringUtil.removeChars(str, "abcdefghijklmnopqrst $");
    System.out.println(cost);
  }

}
   

It gives the following output,
1234
48



 
  


  
bl  br