Java tutorial
//package com.java2s; public class Main { /** * * replaces in text all <action="actionId"> with correspondent shortcut. */ public static String replacement(String text) { String result = text; final String TAG = "action"; while (result.contains("<" + TAG + "=\"")) { int start = result.indexOf("<" + TAG + "=\""); int end = result.indexOf("\">", start); String value = result.substring((start + 3 + TAG.length()), end); String replaceString = "ACTION"; result = result.substring(0, start) + replaceString + result.substring(end + 2); } return result; } }