Regex 正在查找包含一组单词的正则表达式
我正在尝试为我的后缀头检查文件创建一个正则表达式,这样它将匹配一个不包含.com、.net或.org域扩展名的字符串 以下正则表达式似乎在regex101中工作,但在后缀中失败Regex 正在查找包含一组单词的正则表达式,regex,pcre,postfix,Regex,Pcre,Postfix,我正在尝试为我的后缀头检查文件创建一个正则表达式,这样它将匹配一个不包含.com、.net或.org域扩展名的字符串 以下正则表达式似乎在regex101中工作,但在后缀中失败 /^From: .*\.(?!(com|net|org)>)/ HOLD 所有邮件(包括.com、.net等)都会被排队,这显然不是我想要的 我希望正则表达式与以下字符串匹配: From: Example Mail <example@domain.bid> From: Example Mail <
/^From: .*\.(?!(com|net|org)>)/ HOLD
所有邮件(包括.com、.net等)都会被排队,这显然不是我想要的
我希望正则表达式与以下字符串匹配:
From: Example Mail <example@domain.bid>
From: Example Mail <example@domain.bid.co>
From:示例邮件
发件人:示例邮件
你知道我的正则表达式哪里出了问题吗?根据正则表达式,它与多行匹配
模式关闭,这意味着^
只匹配字符串的开头,而不匹配字符串的开头
这条线的起点
By default, matching is case-insensitive, and newlines are not treated
as special characters. The behavior is controlled by flags, which are
toggled by appending one or more of the following characters after the
pattern:
i (default: on)
Toggles the case sensitivity flag. By default, matching is case
insensitive.
m (default: off)
Toggle the multi-line mode flag. When this flag is on, the ^ and
$ metacharacters match immediately after and immediately before
a newline character, respectively, in addition to matching at
the start and end of the input string.
默认情况下,匹配不区分大小写,不处理换行符
作为特殊人物。行为由标志控制,这些标志是
通过在
模式:
i(默认值:开)
切换区分大小写标志。默认情况下,匹配为大小写
不敏感的
m(默认值:关闭)
切换多行模式标志。当此标志处于启用状态时,^和
$metacharacters在紧接之后和紧接之前匹配
一个换行符,除了在
输入字符串的开始和结束。
(顺便说一句,我更喜欢“[.]”
而不是“\.”
,并且会使用非捕获组作为替代:“(?:com | net | org)”
)