How can I find a string after a specific string/character using regex

  • Thread starter Thread starter superlurker
  • Start date Start date
S

superlurker

Guest
This is what I have that was working for wile..

using (WebClient client = new WebClient())
{
client.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
try
{
try
{
byte[] store = client.DownloadData(StateWebLocation);
string Data = System.Text.Encoding.UTF8.GetString(store);

pattern = @",?\d,\d,\d\s*</div>";

string Data2 = Regex.Replace(Data, @"\s", "");
foreach (Match m in Regex.Matches(Data2, pattern, RegexOptions.Singleline))
{
string t = m.ToString();
if ("," != t.Substring(0, 1))
{
t = Regex.Replace(t, "[^.0-9]", "");
myList.Add(t);
}
}

The problem is that the web site format has changed.. to this.......

<a class="c-table-group__model-header" href="/at/laptop">
Model 1
</a>
</td>
<td class="c-table__td c-table-collapsible__td c-table-group__result u-order-3@tablet u-flex-5" data-link=/at/laptop data-header="Result">


<div class="c-model-group js-model-group ">
<div class="c-model-group__numbers">

<span class="c-model js-model c-model--outline">
1
</span>

<span class="c-model js-model c-model--outline">
2
</span>

<span class="c-model js-model c-model--outline">
3
</span>
</div>
</div>

What I'm trying to do is after the key word search in data " Model 1" and "Model 2"

look for this grouping of 3 numbers and merge to one string "It's just on model number broke up.." Model 2 has 4 numbers.

and add it to myList. Some time there are 2 different sets of numbers... I need both if there is another one.

little lost on how to grab the data the correct way.. any ideas ?


Thanks

Continue reading...
 
Back
Top