正则表达式,从匹配的字符串中排除“,”

问题描述

您好! 我有这个正则表达式:

Regex

您可以看到正则表达式(?:-|role:)??\binfo-ansible[\s|,] 我试图在这种情况下将所有字符串“ info-ansible”与规则匹配:

  • 必须以“-”或“ role:”开头(例如:角色:info-ansible)
  • 它必须以空格或“,”结束

这些规则已在正则表达式中实现

在第一场比赛中,您可以看到它与info-ansible,相匹配 我不希望比赛中包含“,”。

似乎是一个非常简单的问题,但我已经花了很多时间。

链接到在线正则表达式工具的链接中包含以下文本:https://regex101.com/r/Xixz3O/3

解决方法

#include <type_traits> #include <vector> template<class T> struct my_struct { my_struct() {} explicit my_struct(T) {} template <typename U = T> explicit my_struct(std::vector<U>,std::enable_if_t<!std::is_const_v<U>,int> = 0) {} }; int main() { my_struct<const int> s(1); my_struct<int> t({1,2}); } 捕获中使用positive lookahead

因此,使用pip install setuptools==49.6.0 代替whitespace|comma

[\s|,]

Try it online!


简体(Thx @Wiktor Stribiżew);

(?=[\s,])

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...