Regular expressions

A regular expression (or regex) is a string of characters, (some of which being reserved control characters,) which represent a pattern [1], i.e. a string which is designed to match a particular type of strings. Regular expressions provide the basic tool in searching, and are ubiquitous in the electronic world.

Getting started

There are many editors with regex functionalities. Here are a few examples (Please feel free to add or remove if you find better ones.)

A lightning introduction

There are several "dialects" (e.g. javascript, perl, php, python) of regular exprssions which differ slightly in grammar. Let us focus on python regex for the moment (because I happen to have a reference [2] for it).

Control characters

\-.*+?$<!=|()[]^:#

First examples

[please verify]

Exercises

Write your proposed solutions below

Further lessons

[proposals]

Wikimedia links

External links

Notes

  1. Martelli, Python in a nutshell, p.203
  2. Alex Martelli, Python in a nutshell ISBN 0596100469


This article is issued from Wikiversity - version of the Friday, August 30, 2013. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.