Content deleted Content added
Mindmatrix (talk | contribs) rm link per WP:ELNO; formatting: 17x whitespace, 3x mdash (using Advisor.js) |
|||
Line 3:
{{examplefarm}}
A [[regular expression]] ( also "RegEx" or "regex" ) is a string that is used to describe or match a set of strings according to certain [[syntax]] rules. The specific syntax rules vary depending on the specific [[implementation]], [[programming language]], or [[Library (computing)|library]] in use. Additionally, the functionality of regex implementations can vary between [[Software versioning|version]]s.
Despite this variability, and because regular expressions can be difficult to both explain and understand without examples, this article provides a basic description of some of the properties of regular expressions by way of illustration.
== Conventions ==
Line 11:
metacharacter(s) ;; the metacharacters column specifies the regex syntax being demonstrated
=~ m// ;; indicates a regex '''match''' operation in perl
=~ s/// ;; indicates a regex '''substitution''' operation in perl
Line 18:
== Examples ==
Unless otherwise indicated, the following examples conform to the [[Perl]] programming language, release 5.8.8, January 31, 2006. The syntax and conventions used in these examples coincide with that of other programming environments as well (e.g., see Java in a Nutshell
<table class="wikitable">
Line 39:
</pre></td>
</tr>
<tr>
<td>( )</td>
Line 82:
</pre></td>
</tr>
<tr>
<td>?</td>
Line 96:
</pre></td>
</tr>
<tr>
<td>*</td>
Line 109:
</pre></td>
</tr>
<tr>
<td>{M,N}</td>
Line 123:
</td>
</tr>
<tr>
<td>[...]</td>
Line 135:
</pre></td>
</tr>
<tr>
<td>|</td>
Line 148:
</pre></td>
</tr>
<tr>
<td>\b</td>
Line 162:
</pre></td>
</tr>
<tr>
<td>\w</td>
Line 175:
</pre></td>
</tr>
<tr>
<td>\W</td>
Line 201:
</pre></td>
</tr>
<tr>
<td>\S</td>
Line 214:
</pre></td>
</tr>
<tr>
<td>\d</td>
Line 229:
</pre></td>
</tr>
<tr>
<td>\D</td>
Line 242:
</pre></td>
</tr>
<tr>
<td>^</td>
Line 254:
</pre></td>
</tr>
<tr>
<td>$</td>
Line 319:
[[Category:Articles with example code]]
[[Category:Programming language topics]]
|