Regular Expression

From TBwiki
(Difference between revisions)
Jump to: navigation, search
Line 8: Line 8:
 
This section provides a quick reference.  
 
This section provides a quick reference.  
  
= Definition<br>  =
+
== Definition<br>  ==
  
 
Regular expressions is the term used for a codified method of searching invented or defined by the American mathematician Stephen Kleene.<br>  
 
Regular expressions is the term used for a codified method of searching invented or defined by the American mathematician Stephen Kleene.<br>  
  
== POSIX definition  ==
+
=== POSIX definition  ===
  
 
Traditional Unix regular expression syntax followed common conventions but often differed from tool to tool. The IEEE POSIX 1003.2 Basic Regular Expressions (BRE) standard (released alongside an alternative flavor called Extended Regular Expressions or ERE) was designed mostly for backward compatibility with the traditional (Simple Regular Expression) syntax but provided a common standard which has since been adopted as the default syntax of many Unix regular expression tools, though there is often some variation or additional features.<br>  
 
Traditional Unix regular expression syntax followed common conventions but often differed from tool to tool. The IEEE POSIX 1003.2 Basic Regular Expressions (BRE) standard (released alongside an alternative flavor called Extended Regular Expressions or ERE) was designed mostly for backward compatibility with the traditional (Simple Regular Expression) syntax but provided a common standard which has since been adopted as the default syntax of many Unix regular expression tools, though there is often some variation or additional features.<br>  
  
== Perl-derivative<br>  ==
+
=== Perl-derivative<br>  ===
  
 
Perl has a more consistent and richer syntax than the POSIX basic (BRE) and extended (ERE) regular expression standards. An example of its consistency is that \ always escapes a non-alphanumeric character. Another example of functionality possible with Perl but not POSIX-compliant regular expressions is the concept of lazy quantification (see the next section).  
 
Perl has a more consistent and richer syntax than the POSIX basic (BRE) and extended (ERE) regular expression standards. An example of its consistency is that \ always escapes a non-alphanumeric character. Another example of functionality possible with Perl but not POSIX-compliant regular expressions is the concept of lazy quantification (see the next section).  
Line 24: Line 24:
 
<br>  
 
<br>  
  
= Toolpack and regular expressions  =
+
== Toolpack and regular expressions  ==
  
[[Toolpack Application:gateway]]&nbsp;makes use of Perl-derivative regular expressions for route matching and remapping.[[Toolpack v2.2:Creating Called Number Routes|Toolpack v2.2:Creating Called Number Routes]] <br>
+
[[Toolpack Application:gateway]]&nbsp;makes use of Perl-derivative regular expressions for route matching and remapping.[[Toolpack v2.2:Creating Called Number Routes|Toolpack v2.2:Creating Called Number Routes]] <br>  
  
The Gateway application make uses of:<br>
+
The Gateway application make uses of:<br>  
  
*PCRE&nbsp;regex syntax for the base routing engine.<br>
+
*PCRE&nbsp;regex syntax for the base routing engine.<br>  
*Ruby regex syntax for the [[Scriptable_Routing_Engine]].<br>
+
*Ruby regex syntax for the [[Scriptable Routing Engine]].<br>
  
'''''Note''''': Both PCRE and Ruby syntax are compatible (Perl-derivative). <br>
+
'''''Note''''': Both PCRE and Ruby syntax are compatible (Perl-derivative). <br>  
  
 +
<br>
  
 +
== References  ==
  
= References  =
+
=== Internal  ===
 
+
== Internal  ==
+
  
 
[[Web Portal Tutorial Guide Versions]]  
 
[[Web Portal Tutorial Guide Versions]]  
Line 49: Line 49:
 
<br>  
 
<br>  
  
== External  ==
+
=== External  ===
  
 
[http://en.wikipedia.org/wiki/Regular_expression Regular Expression on Wikipedia]  
 
[http://en.wikipedia.org/wiki/Regular_expression Regular Expression on Wikipedia]  
Line 55: Line 55:
 
[http://www.regular-expressions.info/quickstart.html www.regular-expressions.info/quickstart.html]  
 
[http://www.regular-expressions.info/quickstart.html www.regular-expressions.info/quickstart.html]  
  
[[Category:Glossary]]
+
<br>
  
<br>
+
[[Category:Glossary]]

Revision as of 15:17, 26 January 2010

Contents

Introduction

Regular expressions, also referred to as regex or regexp, provides a concise and flexible means for matching strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in a formal language that can be interpreted by a regular expression processor, a program that either serves as a parser generator or examines text and identifies parts that match the provided specification.

Regular expressions are extensively used in computing and is really powerful. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager, the equivalent regex would be :

/.*\.txt$/

This section provides a quick reference.

Definition

Regular expressions is the term used for a codified method of searching invented or defined by the American mathematician Stephen Kleene.

POSIX definition

Traditional Unix regular expression syntax followed common conventions but often differed from tool to tool. The IEEE POSIX 1003.2 Basic Regular Expressions (BRE) standard (released alongside an alternative flavor called Extended Regular Expressions or ERE) was designed mostly for backward compatibility with the traditional (Simple Regular Expression) syntax but provided a common standard which has since been adopted as the default syntax of many Unix regular expression tools, though there is often some variation or additional features.

Perl-derivative

Perl has a more consistent and richer syntax than the POSIX basic (BRE) and extended (ERE) regular expression standards. An example of its consistency is that \ always escapes a non-alphanumeric character. Another example of functionality possible with Perl but not POSIX-compliant regular expressions is the concept of lazy quantification (see the next section).

Due largely to its expressive power, many other utilities and programming languages have adopted syntax similar to Perl's — for example, Java, JavaScript, PCRE, Python, Ruby, Microsoft's .NET Framework, and the W3C's XML Schema all use regular expression syntax similar to Perl's.


Toolpack and regular expressions

Toolpack Application:gateway makes use of Perl-derivative regular expressions for route matching and remapping.Toolpack v2.2:Creating Called Number Routes

The Gateway application make uses of:

Note: Both PCRE and Ruby syntax are compatible (Perl-derivative).


References

Internal

Web Portal Tutorial Guide Versions

Toolpack v2.2:Creating Called Number Routes

Toolpack v2.3:Creating Called Number Routes


External

Regular Expression on Wikipedia

www.regular-expressions.info/quickstart.html


Personal tools