如何解决正则表达式规范中的某些语法问题
我一直收到这个非常烦人的错误:
E: Error parsing configuration files:
- routes: Error loading file: while parsing a quoted scalar
in ".magento/routes.yaml",line 14,column 1
found unknown escape character
in ".magento/routes.yaml",column 31
我的文件非常简单。请在下面找到它:
# The routes of the project.
#
# Each route describes how an incoming URL is going to be processed.
#"http://{default}/":
# type: upstream
# upstream: "mymagento:php"
http://{default}/:
type: upstream
redirects:
paths:
"^/catalogsearch/result((/)|(/\?)|(/\?[a-z])|(/\?[a-z]=))?$": { to: "https://www.example.com/",regexp: true }
我尝试使用双引号和单引号,并且还尝试使用\/
来转义第14行第1列
我不确定我做错了什么,但在这一点上我正在失去情节。在这里需要帮助。预先感谢。
# The routes of the project.
#
# Each route describes how an incoming URL is going to be processed.
#"http://{default}/":
# type: upstream
# upstream: "mymagento:php"
http://{default}/:
type: upstream
redirects:
paths: ^/catalogsearch/result((/)|(/\\?)|(/\\?[a-z])|(/\\?[a-
z]=))?$ : { to: https:///www.example.com/,regexp: true }
解决方法
反斜杠用于在yaml中转义,因此必须用另一个反斜杠将其转义。将\
替换为\\
,并且不要在值周围使用引号:
paths: ^/catalogsearch/result((/)|(/\\?)|(/\\?[a-z])|(/\\?[a-z]=))?$
您的yaml语法对我来说是错误的或陌生的。我怀疑应该是:
http:
type: upstream
redirects:
paths: ^/catalogsearch/result((/)|(/\\?)|(/\\?[a-z])|(/\\?[a-z]=))?$
to: https://www.example.com/
regexp: true
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。