using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?:https?:\/\/)((?:www\.)|(?:m\.))?soundcloud\.com\/[a-z0-9](?!.*?(-|_){2})[\w-]{1,23}[a-z0-9](?:\/.+)?$";
string input = @"Use only numbers, lowercase letters, underscores, or hyphens.
Profile URLs must not start or end with an underscore or hyphen.
Profile URLs must not have two consecutive underscores or hyphens.
Profile URLs must be between 3 and 25 characters.
http://www.soundcloud.com/fo
http://www.soundcloud.com/foo
https://m.soundcloud.com/abcd123
https://soundcloud.com/abcd123
https://soundcloud.com/
https://m.soundcloud.com/abcd123_l
https://soundcloud.com/abcd123-l
http://www.soundcloud.com/-abcd123
http://www.soundcloud.com/_abcd123
https://m.soundcloud.com/abcd123-_l
https://m.soundcloud.com/abcd123--l
https://m.soundcloud.com/1234567890123456789012345
https://m.soundcloud.com/12345678901234567890123456
https://m.soundcloud.com/1234567890123456789012345/fooo12;lkflkjlfjkljskljflks/
https://m.soundcloud.com/12345678901234567890123456/fooo
http://www.m.soundcloud.com/abcdef";
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