Changes

Jump to: navigation, search

Tutorial9: Regular Expressions

102 bytes added, 10:08, 4 July 2020
Complex Regular Expressions
===Complex Regular Expressions===
<table align="right"><tr valign="top"><td>[[Image:re-4.png|thumb|right|175px|Example of using anchors.]]</td><td>[[Image:re-2.png|thumb|right|200px|Example of matching characters.]]</td><td>[[Image:re-1.png|thumb|right|300px|Example of using character class.]]</td><td>[[Image:re-2.png|thumb|right|200px|Example of matching zero or more occurrence.]]</td></table>The problem with using literals or simple regular expressions is that general patterns are matched.
For example, the pattern “'''the'''” would be matched for larger word containing that pattern like '''there''', '''they''', '''either''', '''them''', '''their''', etc. Another problem is that you may want to search for pattern at a specific location within the string of text (like at the beginning or end).
:*'''Character Class [ ]''' , '''[^ ]'''
:*'''Zero or More Occurrence *'''
 
Examples of how to use these complex regular expressions with the grep command are displayed below:
 
<table align="left"><tr valign="top"><td>[[Image:re-4.png|thumb|right|175px|Example of using anchors.]]</td><td>[[Image:re-2.png|thumb|right|200px|Example of matching characters.]]</td><td>[[Image:re-1.png|thumb|right|300px|Example of using character class.]]</td><td>[[Image:re-2.png|thumb|right|200px|Example of matching zero or more occurrence.]]</td></table>
===Extended Regular Expressions===
13,420
edits

Navigation menu