Last active
August 31, 2018 15:07
-
-
Save lfgrando/36946eeb809bd73d1e68a7718aa8cb8e to your computer and use it in GitHub Desktop.
Many regex helpers
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
var content = "{ \"name\": \"Leandro Grando\" }"; | |
// Remove all spaces and new lines from object | |
var spacelessContent = Regex.Replace(content, @"\s+", string.Empty); | |
// Minify json string | |
var minifiedJson = Regex.Replace(content, "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); | |
// Negate regex - not tested in c# | |
var negated = ^((?!gmail.com).)*$ | |
// Between last "." and ".exe". | |
var between = Regex.Match(Assembly.GetExecutingAssembly().ManifestModule.Name, @"(?<=\.)(\w+?)(?=\.exe$)").Value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment