Tips n Tracks

  • Increase font size
  • Default font size
  • Decrease font size
  • default color
  • black color

Reference

Sample image

Microsoft .NET Framework Get Details.

Sample image

Microsoft .NET Framework Get Details.

Reference

Sample image Microsoft .NET Framework Get Details.
Sample image

Microsoft .NET Framework Get Details.


Finding all words starting with “re” using regular expressions with .net


Finding all words starting with "re" using regular expressions with .net

In this regular expression we are going to find all words starting with "re". Means we are going to search words beginning(first two character) will be "re".

Regular Expression Pattern

(\bre)\w+\b

A description of the regular expression:

[1]: A numbered capture group. [\bre]
\bre
First or last character in a word
re
\w+\b
Alphanumeric, one or more repetitions
First or last character in a word

Sucessful Matches

replace
regex
regular


Read the rest of this entry »

Finding all words ending with “ing” using regular expressions with .net


Finding all words ending with "ing" using regular expressions with .net

In this regular expression we are going to find all words ending with "ing". Means we are going to search words ending(last three character) will be "ing".

Regular Expression Pattern

\b\w+(ing\b)

A description of the regular expression:

\b\w+
First or last character in a word
Alphanumeric, one or more repetitions
[1]: A numbered capture group. [ing\b]
ing\b
ing
First or last character in a word

Sucessful Matches

processing
programming
scripting


Read the rest of this entry »

Text and Data Manipulation with Regular Expressions in .NET Development


Text and Data Manipulation with Regular Expressions in .NET Development

Regular expressions(or regex) is a language used for more sophisticated form and text processing. They are often used to perform complex search-and-replace operations, and to validate that text data is well-formed. Today, regular expressions are supported by most programming languages, as well as many scripting languages (like Perl, ASP, Visual Basic, .NET, C#, Java, JSP, PHP,Python, ColdFusion, Tcl, Ruby and many other languages), editors (EmEditor, TextPad), applications (Microsoft Word, Microsoft Excel, StarOffice, OpenOffice), databases(MySQL, SQL Server), and command-line tools.

Here we see a hands on approach to solve the needs of the majority of RegEx to manipulate data. I have try my best to provide ready to use source for lattest version of ASP.NET, VB.NET, C#.NET. All the example described here are tested with Visual Studio 2008. I have try to cover all important and mostly used regular expressions. If you face with any error or you have new idea which needed to be cover here. Please drop your feedback for me. Ok!, let’s get started…


Read the rest of this entry »

Using Regular Expressions Metacharacters with .net – Greedy and Lazy quantifier


Using Regular Expressions Metacharacters with .net – Greedy and Lazy quantifier

When a regular expression has a quantifier that can accept a range of repetitions (like ".*"), the normal behavior is to match as many characters as possible. Consider the following regular expression:

a.*b The longest string starting with a and ending with b

If this is used to search the string "aabab", it will match the entire string "aabab". This is called "greedy" matching. Sometimes, we prefer "lazy" matching in which a match using the minimum number of repetitions is found. All the quantifiers in Table 2 can be turned into "lazy" quantifiers by adding a question mark "?". Thus "*?" means "match any number of repetitions, but use the smallest number of repetitions that still leads to a successful match". Now let’s try the lazy version of example:

a.*?b The shortest string starting with a and ending with b

If we apply this to the same string "aabab" it will first match "aab" and then "ab".


Read the rest of this entry »

Using Regular Expressions Metacharacters with .net – Captures


Using Regular Expressions Metacharacters with .net – Captures

(exp)

(exp) – Match exp and capture it in an automatically numbered group. Common, unadorned parentheses generally perform two functions, grouping and capturing. Common parentheses are almost always of the form (), but a few flavors use \(\).

(?<name>exp)

(?<name>exp) – Match exp and capture it in a group named name. .NET languages support captures to named locations.

(?:exp)

(?:exp) – Match exp, but do not capture it, but, as the name implies, group regex components for alternation and the application of quantifiers. They are not counted as part of $1, $2, etc. After a match of (1|one)(?:and|or)(2|two), for example, $1 contains ‘1′ or ‘one’, while $2 contains ‘2′ or ‘two’. Grouping-only parentheses are also called non-capturing parentheses.