Regular Expression Examples

From TekiWiki
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]+$