01.12.2012 Views

7 Components: the Function Pages - Developers

7 Components: the Function Pages - Developers

7 Components: the Function Pages - Developers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

You can also make a search take into account differences in orthography<br />

is well, as in:<br />

neighb(o|ou)r(s)<br />

which effects a search for <strong>the</strong> American “neighbor” as well as <strong>the</strong><br />

British “neighbour” in singular and plural.<br />

The real advantage to regular expressions is that you not only can<br />

look for words, but also letter patterns. For instance, you can use<br />

<strong>the</strong>m to search for email addresses or telephone numbers in TWiki.<br />

The basic unit of such patterns is information on permissible letters:<br />

Expression Significance<br />

[acf] One of <strong>the</strong> letters indicated.<br />

[a-g] A letter between (and including) a and g.<br />

[^a] All letters except <strong>the</strong> one indicated.<br />

. any character.<br />

[\-] The minus sign. The backslash functions as a<br />

mask, indicating that <strong>the</strong> following character is<br />

not a function (as in <strong>the</strong> normal function of a<br />

backslash as an area sign).<br />

Instead of letters, you can also use numbers or o<strong>the</strong>r characters. If<br />

such characters have a special function in RegEx, you must “disarm”<br />

<strong>the</strong>m with a preceding backslash. Then, for instance, you can search<br />

for links to films and audio files in TWiki:<br />

\.mp[g3]<br />

It gets even more interesting when you can also indicate how often a<br />

certain character pattern may occur in a row:<br />

Character Frequency<br />

* Never, once or more than once<br />

+ At least once<br />

? At most once<br />

{n} Exactly n times<br />

{n,} At least n times<br />

{n,m} Between n and m times<br />

The characters indicated are placed behind <strong>the</strong> expression whose<br />

size is to be determined. Now we can express a search for singular<br />

and plural words in <strong>the</strong> following way:<br />

Letter patterns<br />

Tab. 13.2<br />

Determine<br />

frequency<br />

Tab. 13.3<br />

13.3 Searching with Regular Expressions �<br />

�<br />

�<br />

197

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!