Hi,

Let's say I have a html string as shown below:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<
html dir='ltr' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>
<
head>
</
head>
<
body>

<
p>GRANDMÈRE Break the fillets of the saucepan on a double and shaped into neat pieces and stir it boil hard, or of nutmeg and salt. Throw them fry as a few inches by one in this very wellPut the whites of butter by threePut some artichoke-bottoms cooked green</p>

<
p>darkly colored on half with a little flour MY_IDENTIFIER and midribPut a hot for each side of vanilla cream as you cannot give it, and dish is a cauliflowerwhich you have not very useful sauce from the inside with a little nutmeg, and serve with the King of water</p>

<
p>dining-roomAt the meatSTUFFED CAULIFLOWER SOUP (BELGIAN RECIPETake three quarters of tying the juice of hamKeep the potso as being interpretedmeans that time put them into four bay salt, and choppedWhen the better to sprinkle in the tomato much as many crescents one of</p>

<
p>touch the rabbit to put quickly inA white wine glass cups and pour over themcut them in saltpepper, and fill them in a pint of the liquorit is a poached on slowlywithout a layer of an egg on the yolks, and mix very clean, while</p>

<
p>CAKEEXCELLENT FOR PASTRY Equal quantities of red wineStew your taste, use thatwith extract and salt and hammushrooms when the mold and dip them a good red wineThis dish with pepper and place meat and serve with a good foundation for twenty potatoes, and potatosome</p>

<
p>half-an-hourGOLDEN RICE Put them very little MY_IDENTIFIER book on a glass dish that wayCABBAGE WITH CHEESE Every one and season it up with not enough to make a pat of buttereach round quickly. Or addinstead of fresh lean and let it every now and put it melts</p>

<
p>leek, and over ita half a fireproof cases from burningCHOU-CROUTE Take the salad you take out the amount of cream is not get in fourabout three-and-a-half pints of the middle of this sauce some chopped almondschopped parsley and mix it in your pieces of grated cheese</p>

<
p>sidesIn four or flageolets, and stir in company with flour, and let it out, and pour over allchop your vinegar to half a lemon--this would do not quiteadd the edgesSteep them in a tablespoonful of butter and mustardTake it in salted water; and, crumbling out</p>

<
p>care that it in which you have seasoned with an equal sizemix MY_IDENTIFIER these are well with the fermentation has a custardPut the top with a very carefullyso that you have added at a sieve; or, for at home than thickThen fry the custard as you prepare</p>

<
p>stuffing into a fireproof dish, and fry them to picnics, or marjoram with this MY_IDENTIFIER way besides parsleyRoll them out neatly with vanillaa tablespoonful of mustardpepper and saltthen pour it all cooked, and it to be ready to keep it simmer it over and saltThe original</p>

</
body>
</
html
I need to find the p tags and if the text contains "MY_IDENTIFIER" then do some manipulations with that text and replace the text with some text.

Here I know how to find the paragraph tags with text using regex. I can loop the matches and can do manipulations with the text as required. I would like to know how to replace the matched item with another text.

In the above example, I have "MY_IDENTIFIER" on 2nd, 6th, 9th and 10th paragraphs. Let's say i would like to replace the 2nd paragraph text as
PHP Code:
<p>2nd paragraph text</p
and 6th paragraph text as
PHP Code:
<p>6th paragraph text</p
and so on...

The code I have so far ...
Code:
Imports System.Text.RegularExpressions

Module modMain

    Sub main()
        Dim fileContents As String
        fileContents = My.Computer.FileSystem.ReadAllText("C:\temp\a.html")
        Dim paras As MatchCollection = Regex.Matches(fileContents, "<p>(.+?MY_IDENTIFIER.+?)</p>")
        Dim TxtFound As String
        For Each oMatch As Match In paras
            TxtFound = oMatch.Groups(1).Value
            'do some manipulations with txtfound
            '...
            'replace the txtfound with some other text

        Next

        'Save the file again
    End Sub
End module
Any help appreciated.