Regular Expression Examples

From TekiWiki
Revision as of 08:51, 25 March 2016 by WikiSysop (Talk | contribs) (1 revision imported)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Regular Expressions are very powerful and quite complex tasks can be achieved with just a few characters. The following example Regular Expressions are simple, frequently used expressions that can be adapted for your own purposes:

Finding Blank Lines

This finds lines that only have spaces! tabs or nothing at all in them:

^[\t ]*$

Finding Trailing Spaces

This finds spaces at the end of the line (note that there is a space at the beginning of the expression):

 +$

Lines that Contain Only Digits

This finds lines that have at least one digit and the whole line contains nothing but digits:

^[0-9]+$