I am trying to replace the MessageParam within the XML tag with XXYY1...

```
The MessageParam has requested to travel <BR/>From <MessageParam name="0" desc="city code"/> to <MessageParam name="1" desc="city code"/> on <MessageParam name="2" desc="date"/> at <MessageParam name="3" desc="time"/>.

```

I expect the output to be 

```
The MessageParam has requested to travel <BR/>From <XXYY1 name="0" desc="city code"/> to <XXYY2 name="1" desc="city code"/> on <XXYY3 name="2" desc="date"/> at <XXYY4 name="3" desc="time"/>.

```

Here is my code 

```
private void ProcessString()
{
    String text = "The Traveler has requested to travel <BR/>From <MessageParam name=\"0\" desc=\"city code\"/> to <MessageParam name=\"1\" desc=\"city code\"/> on <MessageParam name=\"2\" desc=\"date\"/> at <MessageParam name=\"3\" desc=\"time\"/>.";
    int Counter = 0;
    StringBuffer outString = new StringBuffer();
    Pattern pattern = Pattern.compile("(<MessageParam.*?>)");
    Matcher matcher = pattern.matcher(text);

    while (matcher.find())
    {
        Counter++;
        String sReplacer = new StringBuffer("XXYY").append(Counter).toString();
        matcher.appendReplacement(outString, sReplacer);
    }
    matcher.appendTail(outString);
    System.out.println(outString.toString());
  }

```

The output i am getting is

```
 The MessageParam has requested to travel <BR/> From XXYY1 to XXYY2 on XXYY3 at XXYY4.

```

I am pretty sure that my regex is not correct. since i am not good with regex i am not able to figure out whats going wrong.