Regex 带有not includes的正则表达式搜索字符串

Regex 带有not includes的正则表达式搜索字符串,regex,Regex,我有以下内容 database-host-12334-ireland database-host-23233-london database-host-32323-cardiff backup-host-2323232-ireland backup-host-3232323-london 我希望能够搜索所有数据库主机,同时省去爱尔兰主机 我希望搜索只返回2个主机数据库主机: database-host-23233-london database-host-32323-cardiff 我不知道

我有以下内容

database-host-12334-ireland
database-host-23233-london
database-host-32323-cardiff
backup-host-2323232-ireland
backup-host-3232323-london
我希望能够搜索所有数据库主机,同时省去爱尔兰主机

我希望搜索只返回2个主机数据库主机:

database-host-23233-london
database-host-32323-cardiff
我不知道如何从
^数据库主机-[0-9].

任何帮助都将不胜感激,也许这根本不可能。 谢谢

更新上一个问题:

好的,这次有点复杂,您将如何从列表中排除一个数据库主机


您可以使用否定的前瞻断言来排除爱尔兰主机:

database-host-\d+-(?!ireland)\w+

如果出于某种原因无法使用lookarounds,那么在逻辑上实现所需功能的另一种方法是使用两种正则表达式模式,一种用于白名单数据库主机,另一种用于黑名单数据库主机:

database-host-\d+-\w+ && !(database-host-\d+-ireland)

这太棒了,谢谢你,这让我走上了正轨。好的,这次有点复杂,您将如何从列表中排除一个数据库主机?使用
^(?。*\bireland\b)数据库主机-.*
非常感谢,您用这一行代码为我和我的团队省去了这么多的痛苦!!!!
database-host-\d+-\w+ && !(database-host-\d+-ireland)