Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试打印一些“+”字符,然后是一些“-”字符,重复次数由一些简单的算术决定。你能告诉我以下有什么问题吗(这在没有尝试划分的情况下有效):
some-command | perl -pe 's/(\d+) (\d+)/ "+" x ($1 / 4) . "-" x ($2 / 4)/eg'
/需要逃避。尝试:
/
some-command | perl -pe 's/(\d+) (\d+)/ "+" x ($1\/4) . "-" x ($2\/4)/eg'
另一种选择是使用与您的正则表达式不同的字符/:
some-command | perl -pe 's;(\d+) (\d+); "+" x ($1/4) . "-" x ($2/4);eg'