Regex help

M

Marius Trælnes

Hello!

I have a file with following htmlt tags:

.....can be anything before....
<div id="SomeConfig">
some text, can be anything here, also any tag
</div>
.....can be anything after......

I want to "cut" out the div which has an id attribute with config in its's
value. In the above sample
this would be:
<div id="SomeConfig">
some text, can be anything here, also any tag
</div>

I try with this but it does not work:

Dim re As Regex = New Regex("(<div id=.*?config.*?div>)",
RegexOptions.IgnoreCase)
Dim m As Match = re.Match(Text)
Dim s As String = m.Value()

Any suggestions?

Marius
 
M

Michael Persaud

I had a similar experience and the following modified block helped


Dim regexp As Regex = New Regex("<div id=((.|\n)*?)config</div>",
RegexOptions.IgnoreCase)

Dim str As String
Dim objMatch As Match
For Each objMatch In regexp.Matches(text)
str = objMatch.ToString()
Next

Hope this helps

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top