Regex 101
Testing
echo "My stuff" | grep "^My"
Examples
Starts with
echo "A" |grep "^A"
echo "AAAAAAAAAAA" |grep "^A"
Starts with any number of As and Ends With
echo "AAAAAAAAAAAB" |grep "^A*B$
Word Boundries
Was not sure what this meant but what it means is a word in a sentence e.g. quick brown fox so this would be a match
echo "quick brown fox jumps over" |grep "\bfox\b"
And this would not be a match
echo "quick brownfoxjumps over" |grep "\bfox\b"
echo "quick brown foxjumps over" |grep "\bfox\b"
echo "quick brownfox jumps over" |grep "\bfox\b"
Match Start and End with anything in the middle
Look like \b is the better approach to ^ and $
echo "AxxxxxxxB" |grep "\b\A\w*B\b"