?
Solved

Strip first comment

Posted on 2007-07-26
5
Medium Priority
?
249 Views
Last Modified: 2010-04-15
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.
0
Comment
Question by:ansi_c
5 Comments
 
LVL 22

Expert Comment

by:DarkoLord
ID: 19574121
if abcdefg is always the same, you can just use:

string removed = data.Replace("<!-- Generated by abcdefg -->", String.Empty);
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 19574136
Without regex:

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

Author Comment

by:ansi_c
ID: 19574146
No. It's always changing.
And I want a regular expression solution.
0
 
LVL 22

Accepted Solution

by:
DarkoLord earned 500 total points
ID: 19574224
Very well.

data = Regex.Replace(data, "^<!-- Generated by .+? -->", String.Empty);
0
 
LVL 1

Expert Comment

by:mrkarr
ID: 19574343

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);
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question