28 lines
816 B
Bash
Executable File
28 lines
816 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~
|
|
# Experimenting with the meaning of the statement in the GNU Bash Manual:
|
|
# "Any part of the pattern may be quoted to force the quoted portion to
|
|
# be matched as a string."
|
|
# -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~ -~
|
|
|
|
server="hackerpublicradio.org"
|
|
|
|
#
|
|
# Try some regular expressions in a loop. The first is a standard type, but
|
|
# the second and third use a quoted regular expression metacharacter trying
|
|
# different quotes.
|
|
#
|
|
for re in \
|
|
'^(hacker|hobby)publicradio\.org$' \
|
|
'^(hacker|hobby)publicradio"."org$' \
|
|
"^(hacker|hobby)publicradio'.'org$"
|
|
do
|
|
echo "Using regular expression: $re"
|
|
if [[ $server =~ $re ]]; then
|
|
echo "This is HPR"
|
|
else
|
|
echo "No match"
|
|
fi
|
|
done
|