Skip to content

Instantly share code, notes, and snippets.

@sheva29
Last active June 6, 2017 17:12
Show Gist options
  • Save sheva29/6ae2b19cc4c3ee02102795bc627c3660 to your computer and use it in GitHub Desktop.
Save sheva29/6ae2b19cc4c3ee02102795bc627c3660 to your computer and use it in GitHub Desktop.
RegEx
/*
Custom Regular Expressions
To test Regex go here: http://www.regextester.com/
*/
/* 1. Looking for specific Regex with negative look up*/
^((?!For example: Make a left at the blue sign and park by the red door).)*$
/* 2. Setting a maximun Character count*/
^.{1,70}$
/* 3. Get all numbers from inputs*/
\d+
/* 4. Find all double quotations or unicode spaces in a string */
([\"]+)|([\n]+)
/* 5. Find all double-quotation """ except one that is preceded by backslash "\"" "*/
(?<!\\)\x22
/* 6. Remove all quotation marks except at the beginning and end of line or spaces*/
(?<!^)\x22(?<!$)
/* 7. C# getting all numbers from string in getter */
_ContactPhoneNumber = (value.Any(char.IsDigit)) ? Regex.Replace(value, "[^0-9]", "") : value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment