Question: the following takes contents of an HTML file (input)

```
input = input.replaceAll(".*?<span class=\"xgui.*?\">(.*?)</span>.*?", "<cite>$1</cite>");

```

The idea is to remove the span element and leave the contents. Note that the class of the span can be xgui *anything*. However, the code is not working.

It spits out this:

```
 <h4><span class="xguiitem">Primary</span> field </h4>

```

Which is identical to input; ie, it is not doing anything at all.

Any ideas?

Thanks :)

Answer: 
Don't use regexp to manipulate HTML. It may work for some cases, but you are trying to parse a context-free grammar with regular expressions. 
XSLT is the way to go here.
I don't understand why you have those "?" all over, can you try:

```
input = input.replaceAll(".*<span class=\"xgui.*\">(.*)</span>.*", "<cite>$1</cite>");

```