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

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

Validate numbers from 0 to 100

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

Validate numbers from 0 to 100

mahajan344
4/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.

stackoverflow
8/14/2015 1:07:13 PM

Replace
borderlands.wiki add template param

nitrogeniy
1/12/2017 9:58:57 PM
Remove "Style" attribute from HTML tags

Remove all "style" attributes from HTML text.

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

Replace multiple spaces example

stackoverflow
7/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

stackoverflow
7/12/2015 3:52:40 PM

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.

stackoverflow
8/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.

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

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

admin
3/30/2015 12:45:18 AM