regex - 除特定字符串外,每个 URl 的 RegEx 合规性
问题描述
如果通过 URL 重写与国家不匹配,我想自定义 URL 的货币。
我当前在 Apache 上的重写规则如下所示:
RedirectMatch permanent "^/(.*)_DE/(?!.*(EUR))(.*)$" "https://localhost/$1_DE/EUR$2"
因此 URL https://localhost/de_DE/USD必须更改为https://localhost/de_DE/EUR,但不幸的是该规则不适用。
有 Apache RegEx 的网络测试器吗?regex101.com 似乎并不适合 Apache。
解决方案
最终的正则表达式是:
RedirectMatch permanent "^/(.*)_DE/((?!.*EUR)[A-Z{3,3}]+)(.*)$" "https://localhost/$1_DE/EUR$3"
感谢您对网站的帮助
推荐阅读
- swift - 不同设备的 UIScrollview 约束
- javascript - 使用 React Hooks Helper 设置多步表单的状态(链接到代码框)
- python - 将机器学习模型与烧瓶网站集成时出错
- r - 根据条件选择值
- python - 是否可以像在 BeautifulSoup 中一样通过 Scrapy 中的正则表达式查找元素
- python-3.x - 当我运行 subprocess.run 命令时,出现 `AttributeError: 'list' object has no attribute 'read'` 错误
- sql - 复制到 pgadmin 时在数据错误和日期/时间字段值超出范围错误中发现未加引号的换行符
- mongodb - pymongo ServerSelectionTimeoutError
- r - 将 ARIMA 预测结果导出到 excel 文件中
- c# - 正则表达式不等于在 C# 字符串数组中不起作用