using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<code1>id=""question-summary-)(?<code2>\d+)";
string input = @"<div class=""question-summary"" id=""question-summary-80407"">
<div class=""statscontainer"">
<div class=""statsarrow""></div>
<div class=""stats"">
<div class=""vote"">
<div class=""votes"">
<span class=""vote-count-post ""><strong>2</strong></span>
<div class=""viewcount"">votes</div>
</div>
</div>
<div class=""status answered"">
<strong>1</strong>answer
</div>
</div>
<div class=""views "" title=""60 views"">
60 views
</div>
</div>
<div class=""summary"">
<h3><a href=""/questions/80407/about-power-supply-of-opertional-amplifier"" class=""question-hyperlink"">about power supply of opertional amplifier</a></h3>
<div class=""excerpt"">
I am constructing an operational amplifier as shown in the following figure. I use a batter as supplier for the OP Amp and set it up as a non-inverting amp circuit. I saw that the output was clipped ...
</div>
<div class=""tags t-op-amp"">
<a href=""/questions/tagged/op-amp"" class=""post-tag"" title=""show questions tagged 'op-amp'"" rel=""tag"">op-amp</a>
</div>
<div class=""started fr"">
<div class=""user-info "">
<div class=""user-action-time"">
asked <span title=""2013-08-27 21:49:14Z"" class=""relativetime"">11 hours ago</span>
</div>
<div class=""user-gravatar32"">
<a href=""/users/17060/user1285419""><div class=""><img src=""https://www.gravatar.com/avatar/08ee68b20a4eceff26f7eee99b708c08?s=32&d=identicon&r=PG"" alt="" width=""32"" height=""32""></div></a>
</div>
<div class=""user-details"">
<a href=""/users/17060/user1285419"">user1285419</a><br>
<span class=""reputation-score"" title=""reputation score"" dir=""ltr"">165</span><span title=""5 bronze badges""><span class=""badge3""></span><span class=""badgecount"">5</span></span>
</div>
</div>
</div>
</div>
</div>
<div class=""question-summary"" id=""question-summary-80405"">
<div class=""statscontainer"">
<div class=""statsarrow""></div>
<div class=""stats"">
<div class=""vote"">
<div class=""votes"">
<span class=""vote-count-post ""><strong>4</strong></span>
<div class=""viewcount"">votes</div>
</div>
</div>
<div class=""status answered-accepted"">
<strong>2</strong>answers
</div>
</div>
<div class=""views "" title=""64 views"">
64 views
</div>
</div>
<div class=""summary"">
<h3><a href=""/questions/80405/5v-regulator-power-dissipation"" class=""question-hyperlink"">5V Regulator Power Dissipation</a></h3>
<div class=""excerpt"">
I am using a 5V regulator (LP2950) from ON Semiconductor. I am using this for USB power and I'm feeding in 9V from an adapter. USB requires maximum of 500mA right? So the maximum power dissipation in ...
</div>
<div class=""tags t-voltage-regulator t-surface-mount t-heatsink t-5v t-power-dissipation"">
<a href=""/questions/tagged/voltage-regulator"" class=""post-tag"" title=""show questions tagged 'voltage-regulator'"" rel=""tag"">voltage-regulator</a> <a href=""/questions/tagged/surface-mount"" class=""post-tag"" title=""show questions tagged 'surface-mount'"" rel=""tag"">surface-mount</a> <a href=""/questions/tagged/heatsink"" class=""post-tag"" title=""show questions tagged 'heatsink'"" rel=""tag"">heatsink</a> <a href=""/questions/tagged/5v"" class=""post-tag"" title=""show questions tagged '5v'"" rel=""tag"">5v</a> <a href=""/questions/tagged/power-dissipation"" class=""post-tag"" title=""show questions tagged 'power-dissipation'"" rel=""tag"">power-dissipation</a>
</div>
<div class=""started fr"">
<div class=""user-info "">
<div class=""user-action-time"">
asked <span title=""2013-08-27 21:39:31Z"" class=""relativetime"">11 hours ago</span>
</div>
<div class=""user-gravatar32"">
<a href=""/users/10082/david-norman""><div class=""><img src=""https://www.gravatar.com/avatar/8b073417e471077280b3fc5ff2eaf1f7?s=32&d=identicon&r=PG"" alt="" width=""32"" height=""32""></div></a>
</div>
<div class=""user-details"">
<a href=""/users/10082/david-norman"">David Norman</a><br>
<span class=""reputation-score"" title=""reputation score"" dir=""ltr"">322</span><span title=""3 silver badges""><span class=""badge2""></span><span class=""badgecount"">3</span></span><span title=""10 bronze badges""><span class=""badge3""></span><span class=""badgecount"">10</span></span>
</div>
</div>
</div>
</div>
</div>";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx