Open main menu

CDOT Wiki β

Changes

Tutorial9: Regular Expressions

6 bytes removed, 08:33, 6 July 2020
INVESTIGATION 1: SIMPLE & COMPLEX REGULAR EXPRESSIONS
# 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 "^[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 "^^[0-9][0-9][0-9]$" textfile1.txt | more</span><br><br>
13,420
edits