Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        String temp = "<NOUN>Nitin<NOUN> <NOUN>test<NOUN>";
        String finalString = "this is a test";

        StringTokenizer x = new StringTokenizer(temp, " ");
        while (x.hasMoreTokens()) {

            String token = x.nextToken();

            String findword = token.replaceAll("<NOUN>", "");
            String findword1 = findword.replaceAll("</NOUN>", "");

            String modifiedString = finalString.replaceFirst(findword1, "<NOUN>" + findword1 + "</NOUN>");
            finalString = modifiedString;
        }
        System.out.println(finalString);
    }
}