13,420
edits
Changes
→INVESTIGATION 1: SIMPLE & COMPLEX REGULAR EXPRESSIONS
#Issue the following linux pipeline command to match the pattern the within '''textfile1.txt''':<br><span style="color:blue;font-weight:bold;font-family:courier;">grep "the" textfile1.txt | more<br><br>
# Now, issue the grep linux pipeline command with the '''-i''' option to ignore case sensitively:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -i "the" textfile1.txt | more</span><br><br>What do you notice is different with this pipeline command?<br><br>You will notice that the pattern "the" is matched including larger words that contain the pattern "the". You can use the -w option with the grep command in order to just match only words for a pattern.<br><br>
# Issue the following linux pipeline command:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -w -i "the" textfile1.txt | more</span><br><br>You should now see only strings of text that match the word '''"the"'''.<br><br>The problem with using literals or simple regular expressions is that general patterns are matched.<br>For Example, you may want to search for pattern at a specific location within the string of text (like at the beginning �or or endof the string).�<br><br>There are other regular expression tools to provide more precise matches. These tools are '''complex ''' and '''extended ''' regular expressions. We will now look at complex regular expression symbols now, and we will discuss complex regular in the next section of this tutorial.<br><br>
#x