Regex match a string with spaces (use quotes?) in an if statement

后端 未结 4 1319
情书的邮戳
情书的邮戳 2021-02-19 11:05

How would I do a regex match as shown below but with quotes around the (\"^This\") as in the real world \"This\" will be a string that can have spaces in it.

#!/         


        
4条回答
  •  礼貌的吻别
    2021-02-19 11:20

    can you make your problem description clearer?

    text="This is just a test string"
    case "$text" in
        "This is"*) echo "match";;
    esac
    

    the above assume you want to match "This is" at exactly start of line.

提交回复
热议问题