By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,640 Members | 1,331 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,640 IT Pros & Developers. It's quick & easy.

Regex help

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
try it with the regexoptions.SingleLine
"Marius Trælnes" <ma*******************@nospamc2i.net> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
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

Nov 21 '05 #2

P: n/a
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
"Marius Trælnes" <ma*******************@nospamc2i.net> wrote in message
news:eC**************@TK2MSFTNGP10.phx.gbl...
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

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.