x Hint: Register, if you want to hide ads.
x Did you like it? Well, then please consider making a donation :)

Regex (or Regexp), Regular Expressions - is a special set of rules that forms a search mask/pattern (mainly for use in work with strings: match, split, replace). Regular expressions are useful in parsing data from text files, websites (html code), xml etc. .NET Regex c#Regular expressions provide a high-power, flexible, and efficient method for processing text: for example get all email addresses from html-file or delete all phone numbers in a text document. The extensive pattern-matching notation of regular expressions enables you to quickly parse large amounts of text to find specific character patterns; to validate text to ensure that it matches a predefined pattern (such as an http link); to parse / extract, replace, edit or delete text substrings; and to add the extracted strings to a collection in order to generate a report. For many applications that deal with strings or that parse large blocks of text, regular expressions are an indispensable tool. Many programming languages provide regular expression capabilities, some built-in, for example Perl, JavaScript, Ruby, AWK, and Tcl, and others via a standard library, for example .NET C#, VB.NET, Java, Python etc.

Each character in a regular expression is either understood to be a metacharacter with its special meaning, or a regular character with its literal meaning. Together, they can be used to identify textual material of a given pattern, or process a number of instances of it that can vary from a precise equality to a very general similarity of the pattern. The pattern sequence itself is an expression that is a statement in a language designed specifically to represent prescribed targets in the most concise and flexible way to direct the automation of text processing of general text files, specific textual forms, or of random input strings. A very simple use of a regular expression would be to locate the same word spelled two different ways in a text editor.

A regex (regular expression) is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs. For a brief introduction, see .NET Framework Regular Expressions. Each section in this quick reference lists a particular category of characters, operators, and constructs that you can use to define regular expressions: anchors, backreference, character escapes, character classes, grouping constructs, quantifiers, substitutions, options and other.

The System.Text.RegularExpressions namespace contains set of classes that provide access to the .NET Framework regular expression engine. The namespace provides .NET regex functionality that may be used from any platform or language that runs within the Microsoft .NET Framework: C#, VB.NET. Learn more: Wikipedia, Microsoft MSDN, Help and Library.


Matches
If else condition on minus sign

If numbers are negative then length of numbers is 11 otherwise 12

mahajan3444/14/2016 10:23:59 PM
Numbers from 0 to 100

Validate numbers from 0 to 100

mahajan3444/14/2016 9:24:49 PM
Numbers from 0 to 100

Validate numbers from 0 to 100

mahajan3444/14/2016 9:24:47 PM
Regex.Matches, Regular Expression for hexadecimal number

Matches expression starting with a 0, following by either a lower or uppercase x, followed by one or more characters in the ranges 0-9, or a-f, or A-F.

stackoverflow8/14/2015 1:07:13 PM

Replace
Remove "Style" attribute from HTML tags

Remove all "style" attributes from HTML text.

admin8/12/2015 5:47:50 PM
How do I replace multiple spaces with a single space?

Replace multiple spaces example

stackoverflow7/12/2015 4:10:18 PM
Remove all non alphanumeric characters from a string except dash & space symbol

Replace this Regex with an empty string + Compiled flag

stackoverflow7/12/2015 3:52:40 PM
Replace and named capturing group example

Nearly all modern regular expression engines support numbered capturing groups and numbered backreferences. Long regular expressions with lots of groups and backreferences may be hard to read. They can be particularly difficult to maintain as adding or removing a capturing group in the middle of the regex upsets the numbers of all the groups that follow the added or removed group.

admin3/30/2015 2:35:04 AM

Split
Split string to get Date and text

I have to process text file like that: text 01/01/1970 text 02/01/1970 ... etc. I want the output to be the following data: according to the docs, wrapping the string you're splitting on in () (making it a capture group) will result in these captures being included in the array.

stackoverflow8/12/2015 4:38:43 PM
Splitting Link using RegEx

i want to find category from the link. I am breaking the link into array using Regex.

admin3/31/2015 5:40:43 PM
Simple Regex.Split sample - remove digits

User \d+ for remove digits and \D+ for remove text.

admin3/30/2015 12:45:18 AM

Last REFERAL links

TimeFromViews
9/27/2016 9:27:12 AMhttp://stackoverflow.com/questions/787932/using-c-sharp-regular-expressions-to-remove-html-tags regex #1,  regex #2366
9/27/2016 8:33:50 AMhttp://stackoverflow.com/questions/14689044/regex-split-on-comma-space-or-semi-colon-delimitted-string regex #1314
9/26/2016 11:00:53 PMhttp://stackoverflow.com/questions/2248411/get-all-links-on-html-page regex #1,  regex #2435
9/23/2016 6:21:03 AMhttp://stackoverflow.com/questions/29388794/need-regular-expression-for-email-id-with-special-characters-space regex #133
9/22/2016 11:11:42 AMhttp://stackoverflow.com/questions/29398389/how-do-i-make-regex-capture-only-named-groups regex #11
9/21/2016 11:05:55 PMhttp://stackoverflow.com/questions/29416568/how-to-replace-substrings-000-000-with-new-guids regex #1,  regex #219
9/19/2016 6:40:06 AMhttp://stackoverflow.com/questions/33715490/regex-to-capture-groups-of-parentheses-including-inner-and-outer-parentheses regex #113
9/8/2016 4:49:07 AMhttp://ru.stackoverflow.com/questions/564135/Замена-по-регулярке regex #1,  regex #2,  regex #3,  regex #410
9/8/2016 3:47:23 AMhttp://ru.stackoverflow.com/questions/564135/Замена-по-регулярке/564161?noredirect=1 regex #1,  regex #2,  regex #34
9/8/2016 3:20:12 AMhttp://ru.stackoverflow.com/questions/564135/Замена-по-регулярке/564161 regex #1,  regex #26
9/5/2016 7:34:03 AMhttp://ru.stackoverflow.com/questions/406873/Как-составить-regex-для-строк/414885 regex #13
8/21/2016 11:27:45 PMhttp://stackoverflow.com/ regex #11
8/1/2016 12:09:55 AMhttp://my.parvazpardaz.com/کار-با-regularexpressions-و-آزمایش-آنلاین/ regex #15
7/13/2016 3:02:47 AMhttp://www.codegur.us/33715490/regex-to-capture-groups-of-parentheses-including-inner-and-outer-parentheses regex #11
6/6/2016 10:09:24 AMhttp://stackoverflow.com/questions/787932/using-c-sharp-regular-expressions-to-remove-html-tags/787951 regex #11
5/21/2016 4:45:09 AMhttp://stackoverflow.com/questions/2248411/get-all-links-on-html-page/31805829 regex #15
4/25/2016 12:18:45 PMhttp://stackoverflow.com/questions/29399436/regex-why-are-the-named-groups-located-at-the-end-of-the-group-array regex #13
12/22/2015 4:55:56 AMhttp://stackoverflow.com/questions/29491588/how-to-split-at-word-not-at-a-char-in-c-sharp?lq=1 regex #13
12/22/2015 4:43:55 AMhttp://stackoverflow.com/questions/31367441/loop-through-list-with-unknown-value-numbers-in-its-rows/31369618 regex #17
12/17/2015 4:11:13 PMhttp://stackoverflow.com/questions/787932/using-c-sharp-regular-expressions-to-remove-html-tags?rq=1 regex #13
11/30/2015 3:01:19 AMhttp://stackoverflow.com/questions/29416568/how-to-replace-substrings-000-000-with-new-guids/29417265 regex #12
10/2/2015 12:58:33 AMhttp://stackoverflow.com/questions/29374698/regex-to-parse-a-duration-string-xxh-yymn-zzs-in-c-sharp/ regex #1108
9/23/2015 1:20:19 PMhttp://ru.stackoverflow.com/questions/406873/Как-составить-regex-для-строк regex #111
9/3/2015 4:38:51 PMhttp://stackoverflow.com/questions/29374698/regex-to-parse-a-duration-string-xxh-yymn-zzs-in-c-sharp regex #11
8/6/2015 2:08:12 PMhttp://www.cnetion.com/regex-to-parse-a-duration-string-xxh-yymn-zzs-in-c-sharp-qq-AUy0R637JGEimGEpEn5C.php regex #13