Regular expression examples: Difference between revisions

Content deleted Content added
Line 8:
 
== Conventions ==
The following conventions are used in the examples.<ref name="clarify000">The character 'm' is not always required to specify a perl[[Perl]] match operation. For example, m/[^abc]/ could also be rendered as /[^abc]/. The 'm' is only necessary if the user wishes to specify a match operation without using a forward-slash as the regex [[delimiter]]. Sometimes it is useful to specify an alternate regex delimiter in order to avoid "[[Delimiter#Delimiter collision|delimiter collision]]". See '[http://perldoc.perl.org/perlre.html perldoc perlre]' for more details.</ref>
 
metacharacter(s) ;; the metacharacters column specifies the regex syntax being demonstrated
=~ m// ;; indicates a regex '''match''' operation in perl[[Perl]]
=~ s/// ;; indicates a regex '''substitution''' operation in perlPerl
 
Also worth noting is that these regular expressions are all Perl-like syntax. Standard [[Regular_expression#POSIX_Basic_Regular_Expressions|POSIX]] regular expressions are different.
 
== Examples ==
Line 20:
Unless otherwise indicated, the following examples conform to the [[Perl]] programming language, release 5.8.8, January 31, 2006. This means that other implementations may lack support for some parts of the syntax shown here (e.g. basic vs. extended regex, \( \) vs. (), or lack of \d instead of [[POSIX]] [:digit:]).
 
The syntax and conventions used in these examples coincide with that of other programming environments as well (e.g., see ''[[Java]] [[O'Reilly_Media#In_a_Nutshell|in a Nutshell]]''&nbsp;— Page 213, ''[[Python]] Scripting for Computational Science''&nbsp;— Page 320, Programming [[PHP]]&nbsp;— Page 106).
 
<table class="wikitable">
Line 321:
{{DEFAULTSORT:Regular Expression Examples}}
[[Category:Perl]]
[[Category:PatternRegular matchingexpressions]]
[[Category:Articles with example code]]
[[Category:Programming constructs]]