爲什麼這個INCREDIBALLY REGEX不匹配?!!?While-Loop BASH-Regex不匹配
#!/bin/bash
while true
do
read -r -p $'What is the JIRA Ticket associated with this work?' JIRA
#Use a regular expresion to verify that our reply stored in JIRA is only 4 digits, if not, loop and try again.
if [[ ! "$JIRA" =~ [0-9]{4} ]]
then
echo -en "The JIRA Ticket should only be 4 digits\nPlease try again."
continue
else
break 1
fi
done
出現提示時,如果輸入「FFFFFF」抓到,但如果你鍵入超過4個位數「444444」,甚至在那裏折騰一個字母「4444444fffff」抓到什麼,打else
塊和退出。我認爲這是基本的,我爲什麼不捕捉額外的數字或字符而傻眼了?
我很感激幫助。
我已經寫現在先進的BASH,大約一年......怎麼會有我從未碰到過?!!?它的工作,並解決了我的問題,所以非常感謝你......也許我以前每次都碰運氣。感謝您幫助我學習新東西! – misteralexander