From d8d9a82c7d5762ae1903d21a433ea743cf9e55d1 Mon Sep 17 00:00:00 2001 From: Jessica Lee Date: Sun, 27 Nov 2022 02:20:15 -0500 Subject: [PATCH 1/2] Add regex example --- regex.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 regex.sh diff --git a/regex.sh b/regex.sh new file mode 100755 index 0000000..62f2445 --- /dev/null +++ b/regex.sh @@ -0,0 +1,40 @@ +#!/bin/bash +#Purpose: regex examples +#Version:1.0 +#Create Date: +#Modified Date: + +# START # + +numString1="1234" +numString2="16789" +numString3="1579" + + +echo "Example 1" +if [[ $numString1 =~ ^1 ]]; then + echo "String \"$numString1\" starts with a \"1\", and matches regex: ^1" +fi + +echo "Example 2" +if [[ $numString2 =~ ^1 ]]; then + echo "String \"$numString2\" starts with a \"1\", and matches regex: ^1" +fi + +echo "Example 3" +if [[ $numString3 =~ ^1.7 ]]; then + echo "String \"$numString2\" starts with a \"1\", followed by any character, and followed by a 7. " + echo "This string matches the regex: ^1.7" +fi + +echo "Example 4" +if [[ ! $numString1 =~ ^1.7 ]]; then + echo "String \"$numString1\" does not start with a \"1\", followed by any character, and followed by a 7. " + echo "This string does not match the regex: ^1.7" +fi + +echo "Example 5" +if [[ $numString2 =~ 9$ ]]; then + echo "String \"$numString2\" ends with a \"9\", and matches the regex: 9$" +fi + From 332cb67716506bcc7637248d29fe96e22641df97 Mon Sep 17 00:00:00 2001 From: jlee882 <87512552+jlee882@users.noreply.github.com> Date: Sun, 27 Nov 2022 02:28:35 -0500 Subject: [PATCH 2/2] Update regex.sh --- regex.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/regex.sh b/regex.sh index 62f2445..376bb77 100755 --- a/regex.sh +++ b/regex.sh @@ -1,7 +1,7 @@ #!/bin/bash #Purpose: regex examples -#Version:1.0 -#Create Date: +#Version: 1.0 +#Create Date: Sun Nov 27 00:27:33 EST 2022 #Modified Date: # START #