首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在"9A“附近的-e第1行,”Bareword“找到了操作员所期望的位置

在"9A“附近的-e第1行,”Bareword“找到了操作员所期望的位置
EN

Stack Overflow用户
提问于 2013-11-27 05:08:24
回答 1查看 3.8K关注 0票数 1

为什么我会有语法错误?

代码语言:javascript
复制
% 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.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-11-27 05:13:05

如果regex包含斜杠,请使用不同的字符和显式m运算符:

代码语言:javascript
复制
perl -ne 'if (m%https://([-.0-9A-Za-z]+\.[-0-9A-Za-z]+)%) { print $1 ; }'

或者:

代码语言:javascript
复制
perl -ne 'print $1 if m{https://([-.0-9A-Za-z]+\.[-0-9A-Za-z]+)}'
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20234354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档