Link to home
Start Free TrialLog in
Avatar of ansi_c
ansi_c

asked on

Strip first comment

I have this

<!-- Generated by abcdefg --><p>sdsdsd</p>

I need to remove the first comment that is <!-- Generated by abcdefg --> and leave the rest intact.
Hopefully, I need to use regex.
Avatar of DarkoLord
DarkoLord
Flag of Slovenia image

if abcdefg is always the same, you can just use:

string removed = data.Replace("<!-- Generated by abcdefg -->", String.Empty);
Avatar of Dirk Haest
Without regex:

        Dim myString As String = "<!-- Generated by abcdefg --><p>sdsdsd</p>"
        myString = myString.Substring(myString.IndexOf("-->") + 3)
Avatar of ansi_c
ansi_c

ASKER

No. It's always changing.
And I want a regular expression solution.
ASKER CERTIFIED SOLUTION
Avatar of DarkoLord
DarkoLord
Flag of Slovenia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

you might want to limit that a bit, if you only have "A-Z" in the list with no spaces

data = Regex.Replace(data, @"^<!-- Generated by \w* -->", String.Empty);