Last active
September 27, 2017 11:47
-
-
Save windwp/8b93e5773209e9f28272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Regex regexObj = new Regex(@"library/(\d*)", RegexOptions.Multiline); | |
resultString = regexObj.Match(subjectString).Groups[1].Value; | |
Console.WriteLine(resultString); | |
} catch (ArgumentException ex) { | |
// Syntax error in the regular expression | |
Console.WriteLine(ex.StackTrace); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C# YouTube regex | |
var youtubeid = Regex.Match(videoUrl, | |
@"^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*") | |
.Groups[7].Value; | |
// remove any tags but not there content "<p>bob<span> johnson</span></p>" becomes "bob johnson | |
Regex.Replace(input, @"<(.|\n)*?>", string.Empty); | |
//remove tags with content "<p>bob<span> johnson</span></p>" becomes "" | |
<.*\s*/?> | |
//remove only specific tag | |
<%TAG%[^>]*>(.*?)</%TAG%> | |
<a[^>]*>(.*?)</a> | |
//remove all tag except br tag | |
(?!<\/?br\s*\/?>)<[^>]+> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment