So Im pretty new to regex, I already use it in my project succefully, but only to find one specific match.
Now im trying to find all matches of a certain url pattern inside an html source code.
The urls are like this:
Link example 1: https://clips.twitch.tv/KindYummyCarrotPeteZaroll?tt_content=video_thumbnail
Link example 2: https://clips.twitch.tv/AmericanOilyMeerkatSaltBae?tt_content=video_thumbnail
I have this code searching for the links:
MatchCollection matches = Regex.Matches(source, @"^(https://clips.twitch.tv/)+(.*?)+(video_thumbnail)$");
if (matches.Count <= 0)
{
MessageBox.Show(matches.Count.ToString() + " urls found");
}
else
{
MessageBox.Show(matches.Count.ToString() + " urls");
}
My first instinc was that the source string was somehow wrong, so I tried this regex in this string:
string source = (" adsfgsdfg adsfg assdfg https://clips.twitch.tv/KindYummyCarrotPeteZaroll?tt_content=video_thumbnail dfgsdfgszdfg asdfg https://clips.twitch.tv/AmericanOilyMeerkatSaltBae?tt_content=video_thumbnailsadfgdf g");
I have tried also this regex:
Regex.Matches(source, @"^(https://clips.twitch.tv/)+([a-z0-9A-Z]{1,100})+(\?)+(tt_content=video_thumbnail)$");
But the result is always 0 urls found.
What im doing wrong?