Categories
PHP
Javascript
MySQL
C#
VB
VB.NET
ASP.NET
Regex
Packaging & compression
General Web Tech
Tech Speak


Google


This website looks best on firefox.
 
Resource Center : Regex : <Regular Expressions: An Introduction>

Regular Expressions: An Introduction

Posted by: Floresense Team
Pages: 1  2  
Regular expressions, a mathematical concept applied into programming languages, opened up varied possiblities of pattern matching in text and strings through programming languages. Its about defining a pattern string and asking the computer to find that string for us from a large text, through a pattern matching algorithm.

An example in PHP:


<?php

$feed = "abcdef";
$pattern = '/def/';
if (preg_match($pattern, $feed))
echo "match found";
else
echo "match not found";
?>


Above code returns "match found" since pattern "def" is found in string "abcdef".

Way back in the linux ages, "Regex" as its now called was more known as 'grep' and was just a command to search a particular text from a list. Slowly it got used in database engines for query matching, and its later versions transformed into what is now 'Regular expressions', became a standard, and every programming langauge has a regex engine implementation supported.

Without this we would have had to develop a lot of string manipulation for every language and this would have been very unstandardized and bad. With regular expressions not just language developers but more so application developers have relief in implementing those innumerous occassions where code has to find a pattern inside a string which could have various forms, especially with standards like XML where strings have structure but still are open to variations.

If not for regular expressions, structures like XML, atom would not have been manoeuverable as easy technologies.

Regular expression engines:
Every implementation of Regex in a language is based on the Regex engine that is used. These engines are bottomline code implementation of the Regex pattern matching standards, and there are many different regex engines available.

People comfortable with XML can relate what a Regex engine does to Regex, as something close to what an xml parser does to xml and more(Infact, it would be ironic this way, because some efficient xml parsers use regex implementation internally to parse the xml string into objects).

Basically, Regular expression is nothing but "a pattern language". We make a string called 'pattern', which defines the kind of string we want to extract from a 'feed' string. And we call the regex engine giving these two strings and some optional parameters to control the matching algorithm.
And it is because that different programming languages use different Regex engines for implementing it, there might be a case where the same regex pattern which works in PHP might not work for .NET or a Java implementation.

Related Links:


Regex and C,C++
dmoz.org Links for Regex and C++
Dr.Dobbs Regular Expressions in C++

Regex and VB
ASP Alliance: VBScript Regular expressions
Microsoft Beefs up VBScript with Regular Expressions - Microsoft's guide to using Regular Expressions with VBScript.

Regex and .Net
RegexTester in VB.NET
Regex Class (.NET Framework)
ASP.NET.4GuysFromRolla.com: Regular Expressions in .NET
.NET 247 : System.Text.RegularExpressions.Regex Class [Articles]

(More links in next page)
Pages: 1  2  

Advertisement

2005 - 2008 © Floresense.com