Difference between revisions of "regular expressions"
Jump to navigation
Jump to search
(→Articles: an example) |
(→Examples: corrected MediaWiki example; added example of detecting repetitions) |
||
Line 7: | Line 7: | ||
* [[regex manpage]] | * [[regex manpage]] | ||
==Examples== | ==Examples== | ||
− | * \[http://[a-z|.|\-]+\.[a-z|.|\-]+[a-z|.|\-/]* [a-z| | + | * \[http://[a-z|0-9|\.|\-]+\.[a-z|0-9|.|\-]+[a-z|0-9|\.|\-\/]* [a-z|0-9| ]+\]( )* |
** matches a link in [[MediaWiki]] markup (it could probably be more precise, but catches most of them) | ** matches a link in [[MediaWiki]] markup (it could probably be more precise, but catches most of them) | ||
+ | * (\[http://[a-z|0-9|\.|\-]+\.[a-z|0-9|.|\-]+[a-z|0-9|\.|\-\/]* [a-z|0-9| ]+\]( )*){5,} | ||
+ | ** matches at least 6 links in a row with nothing except spaces between them; good for detecting spam |
Revision as of 16:14, 30 September 2007
computing: software: programming: regex
Overview
Regex is shorthand for "Regular Expressions", a syntax used in string matching and replacement. It is especially heavily used in Perl, and the Linux utility grep is basically a front end for regex geared towards file-searching.
Articles
Examples
- \[http://[a-z|0-9|\.|\-]+\.[a-z|0-9|.|\-]+[a-z|0-9|\.|\-\/]* [a-z|0-9| ]+\]( )*
- matches a link in MediaWiki markup (it could probably be more precise, but catches most of them)
- (\[http://[a-z|0-9|\.|\-]+\.[a-z|0-9|.|\-]+[a-z|0-9|\.|\-\/]* [a-z|0-9| ]+\]( )*){5,}
- matches at least 6 links in a row with nothing except spaces between them; good for detecting spam