tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Jodd > Strings > String replace all

String replace all 

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.replace() API. It replaces all occurrences of specified pattern in a string with a replacement string.

File Name  :  
com/bethecoder/tutorials/jodd/utils/StringReplaceAllTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.jodd.utils;

import jodd.util.StringUtil;

public class StringReplaceAllTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    System.out.println(StringUtil.replace("abcabcabc""abc""xyz"));
    System.out.println(StringUtil.replace("abcabcabc""b""Z"));
    System.out.println(StringUtil.replace("xyxyxy""yx""YX"));
  }

}
   

It gives the following output,
xyzxyzxyz
aZcaZcaZc
xYXYXy


                    Print

   



Books Recommendation

 
 
bl  br