Changes

Jump to: navigation, search

Tutorial9: Regular Expressions

18 bytes removed, 08:32, 6 July 2020
INVESTIGATION 1: SIMPLE & COMPLEX REGULAR EXPRESSIONS
# 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>What do you notice?<br><br>
# Issue the following Linux pipeline command to anchor the work "the" simultaneously at the beginning and the end of the string:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -w -i "^the$" textfile1.txt | more</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 for more complex search patterns.<br>We will now be demonstrating simultaneous anchoring with other complex regular expressions symbols.<br><br>
# Issue the following command to match strings that begin with 3 characters:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -w -i "^..." textfile1.txt | more</span><br><br>What do you notice?<br><br>
# Issue the following command to match strings that begin and end with 3 characters:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -w -i "^...$" textfile1.txt | more</span><br><br>What do you notice?<br><br>
# Issue the following command to match strings that begin with 3 digits:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -w -i "^[0-9][0-9][0-9]" textfile1.txt | more</span><br><br>
# Issue the following command to match strings that end with 3 uppercase letters:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -w -i "[A-Z][A-Z][A-Z]$" textfile1.txt | more</span><br><br>
# Issue the following command to match strings that consist of only 3 digits:<br><span style="color:blue;font-weight:bold;font-family:courier;">grep -w -i "^^[0-9][0-9][0-9]$" textfile1.txt | more</span><br><br>
=INVESTIGATION 2: EXTENDED REGULAR EXPRESSIONS =
13,420
edits

Navigation menu