Hello shapper,
> Hello,
>
> I have a String as follows:
>
> <p class="Error">Some text</p>
>
> I need to wrap the inner text "Some text" in a span tag like:
>
> <p class="Error"><span>Some text</span></p>
>
> I can't make a direct replace because the paragraph class can be: <p>,
> <p class="SomeClass">, <p class="SomeClass" id="MyP">, ...
>
> Any idea how to make this?
>
> I was thinking in Regex but I don't know how and I am not even sure if
> it is the best option.
have a look at the HTML Agility Pack, I think that willallow you to use an
XSL Transfor to add the values you're looking for. Alternatively, this can
be done with a Regex, but you'd need to provide a little more info on the
possible examples where you DO and where you DON'T want to replace...
something like (<P[^>]*>)((?

?!</P).)*)
and replace that with
$1<span>$2</span>
should get you going... But mind you that there are a lot of conditions that
might not work with such a simple regex. And that it migth be impossible
to think up one that will work under all conditions. My advice is, if it's
for a one off conversion, use it. If you want to use it regularly (like in
a production environment) don't.
--
Jesse Houwing
jesse.houwing at sogeti.nl