Created
July 31, 2018 01:48
-
-
Save shinriyo/d0adb08bb8f1c072007357ac8c17391f to your computer and use it in GitHub Desktop.
東京医科歯科大学と東京医科大学と東京歯科大学全てにマッチするbash正規表現
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
univ="東京医科歯科大学" | |
if [[ ${univ} =~ ^東京(医科)?(歯科)?大学$ ]]; then | |
all=${BASH_REMATCH[0]} | |
echo part1. ${all} | |
fi | |
univ="東京医科大学" | |
if [[ ${univ} =~ ^東京(医科)?(歯科)?大学$ ]]; then | |
echo part2. ${all} | |
fi | |
univ="東京歯科大学" | |
if [[ ${univ} =~ ^東京(医科)?(歯科)?大学$ ]]; then | |
echo part3. ${all} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
違いの覚え方