using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"\b(?<url>(https?:.//?|www\.).*?)(?:</ref>)";
string input = @"=== Cette page est utilisé pour tester un maximum de scénarios différents pour l'outil WikiRef. ===
=== <u>Merci de ne pas y toucher</u> ===
<ref>Melon busk + shorten domain https://www.youtube.com/watch?v=2j3p_aDMTNg</ref>
<ref>vidéo privé http://www.youtube.com/watch?v=yZ-K7nCVnBI&playnext_from=TL&videos=osPknwzXEas&feature=sub</ref>
<ref>rick roll http://youtu.be/dQw4w9WgXcQ?feature=youtube_gdata_playe</ref>
<ref>ajout source redirect home page - http://youtube.com/watch?vi=dQw4w9WgXcQ&feature=youtube_gdata_player</ref>
<ref>rick roll avec share https://youtube.com/shorts/dQw4w9WgXcQ?feature=share'</ref>
<ref>Video indisponible (pas TOS, pas privé) - https://www.youtube-nocookie.com/embed/up_lNV-yoK4?rel=0%2C</ref>
<ref>lien de chaine https://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo</ref>
<ref>chaine indisponnible http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I</ref>
<ref>video indisponnible https://www.youtube.com/watch?v=yZ-K7nCVnBI&playnext_from=TL&videos=osPknwzXEas&feature=sub</ref>
<ref>Embedded video https://www.youtube.com/embed/nas1rJpm7wY?rel=0</ref>
<ref> Multiple url reference [https://www.youtube.com/watch?v=ubNF9QNEQLA, https://www.youtube.com/watch?v=ubNF9QNEQLA]</ref>
<ref> nowiki referefence <nowiki>https://www.youtube.com/watch?v=ubNF9QNEQLA</nowiki></ref>
<references />
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
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