Changes

Jump to: navigation, search

Tutorial9: Regular Expressions

7 bytes added, 09:32, 28 February 2021
INVESTIGATION 1: SIMPLE & COMPLEX REGULAR EXPRESSIONS
# Issue the following Linux command to anchor the <u>word</u> "'''the'''"<br>simultaneously at the <u>beginning</u> and <u>end</u> of the string:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -w -i "^the$" textfile1.txt </span><br><br>What do you notice?<br><br>Anchoring patterns at both the <u>beginning</u> and <u>ending</u> of strings can greatly assist<br>for more '''precise''' search patterns.<br><br>We will now be demonstrate the power of anchoring<br>combined with other complex regular expressions symbols.<br><br>
# Issue the following Linux command to match strings that begin with 3 characters:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep "^..." textfile1.txt</span><br><br>What do you notice? Can lines that contain '''less than 3 characters''' be displayed?<br><br>
# Issue the following Linux command to match strings that begin <u>and </u> end with 3 characters:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep "^...$" textfile1.txt</span><br><br>What do you notice compared to the previous command?<br><br>
# Issue the following Linux command to match strings that begin with 3 digits:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep "^[0-9][0-9][0-9]" textfile1.txt</span><br><br>What did you notice?<br><br>
# Issue the following Linux command to match strings that end with 3 uppercase letters:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep "[A-Z][A-Z][A-Z]$" textfile1.txt</span><br><br>Did any lines match this pattern?<br><br>
13,420
edits

Navigation menu