|
Title: Howto: Regular Expressions basics Description: A few tips for getting started with regular expressions.
Regular expressions overview
Several *nix tools are able to utilize regular expressions. For the examples in this howto we will be using grep.
Regular expressions and wildcards
Wildcard characters allow you to specify different possibilities for a single character position. Wildcards include:
Examples with grep: The command grep 'Ti[nm]a Jones' staff-listing The command grep 'ID [0-7][^T]00001' id-file
Regular expressions and word begin / end and line begin / end
The next set of regular expression characters that can be used along with wildcard and regular characters allow you to match based on whether the expression is first or last in a word or line. Ways to match these include:
Examples with grep: The command grep 'Fin$' the-little-prince The command grep '^Welcome to SuSE$' intro The command grep '\<mac' inventory
Regular expressions and repetition
Repetitions of a pattern can be matched for regular characters and wildcards. Ways to match repetitions include:
Examples with grep: The command grep 'C*q' some-file The command grep '[a-w0-3]\{3,99\}' encrypted-fileThe command grep '[5][BC]*[1-9]' new-file Credits: anomie Comments and Suggestions: http://forums.suselinuxsupport.de/index.php?showtopic=23487∞ |
Warning: include(http://forums.suselinuxsupport.de/ssi.php?a=active) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/customers/webs/slwiki/actions/footer.php on line 51
Warning: include() [function.include]: Failed opening 'http://forums.suselinuxsupport.de/ssi.php?a=active' for inclusion (include_path='.:/home/customers/webs') in /home/customers/webs/slwiki/actions/footer.php on line 51
There are no comments on this page. [Add comment]