Skip to content

Instantly share code, notes, and snippets.

@shinriyo
Created July 31, 2018 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinriyo/d0adb08bb8f1c072007357ac8c17391f to your computer and use it in GitHub Desktop.
Save shinriyo/d0adb08bb8f1c072007357ac8c17391f to your computer and use it in GitHub Desktop.
東京医科歯科大学と東京医科大学と東京歯科大学全てにマッチするbash正規表現
#!/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
@shinriyo
Copy link
Author

shinriyo commented Jul 31, 2018

違いの覚え方

  • 東京医科・・・"い"か→い→いの次は「う」→裏口
  • 東京歯科・・・"し"か→し→サ行→再生→半月板の再生をおこなっている
  • 東京医科歯科・・・医科も歯科もあって物知り→本→神保町

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment