using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"http[s]?:\/(?:\/[^\/]+){1,}(?:\/[А-Яа-яёЁ\w ]+\.[a-z]{3,5}(?![\/]|[\wА-Яа-яёЁ]))";
string input = @"https://i.imgur.com/pO5SM73.png
https://i.imgur.com
https://i.imgur.ru/a.gdb
http://bse.sci-lib.com/article089432.html
http://megabook.ru/article/Кошка Собака.png
http://architect.academic.ru/3502/Мансарда
http://megabook.ru/article/%D0%90%D0%BD%D1%82%D0%B0%D0%B1%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82
http://bse.sci-lib.com/a_pictures/17/10/265722250.jpg
http://dic.academic.ru/dic.nsf/stroitel/4
<brbrbr> okk http://fooo-bar.com/more/than/file.exe fdfdfs http://fooo-bar.com/more/than/fil2.exe
http://a.org/ddddd.ddddd
http://a.org/ddddd.dddddв";
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