regular expression: put $ in [ ]

前端 未结 3 1497
粉色の甜心
粉色の甜心 2021-01-22 08:22
echo \"tests\"|perl -pe \"s/s[t$]//g\"
Unmatched [ in regex; marked by <-- HERE in m/s[ <-- HERE 5.020000/ at -e line 1, <> line 1.

Can\'t

3条回答
  •  清歌不尽
    2021-01-22 09:21

    You have to escape the $ sign, because it is a special character:

    echo "tests"|perl -pe "s/s[t\\$]//g"
    

提交回复
热议问题