【发布时间】:2013-11-27 05:08:24
【问题描述】:
为什么会出现语法错误?
% perl -ne 'if (/https://([-.0-9A-Za-z]+\.[-0-9A-Za-z]+)/) { print $1 ; }'
Bareword found where operator expected at -e line 1, near "9A"
(Missing operator before A?)
Bareword found where operator expected at -e line 1, near "9A"
(Missing operator before A?)
syntax error at -e line 1, near "9A"
syntax error at -e line 1, near ";}"
Execution of -e aborted due to compilation errors.
【问题讨论】:
-
您没有注意我在
sed,awk,perlorlex— find strings by prefix+regex ignoring rest of input 上对您的问题的回答。它演示了此处答案中显示的技术。 -
@JonathanLeffler,我是独立完成的(基于stackoverflow.com/a/20172099/1122270),当您的答案中只有
sed(请注意这里也缺少-l),但感谢您的帮助!
标签: perl