如何匹配特定行中包含特定单词的所有文本组?
How to match all groups of text that contain a specific word in a specific line?
我正在尝试创建一个正则表达式来筛选文本文件 (Notepad++) 中的信息,但前提是该字符的名称中包含 "the"。
我现在的表情:\{[\r\n]+id:(.\*?)+name:\s+(\bthe\b)(.*?)[\r\n]\}
{
id: 1
locID: A
tStart: 17:10:00
tEnd: 17:35:00
name: the man 45
text: Lorum Ipsum
}
{
id: 2
locID: A
tStart: 17:11:00
tEnd: 17:12:00
name: Frank
text: Lorum Ipsum
}
{
id: 3
locID: A
tStart: 17:11:00
tEnd: 17:14:00
name: Frank
text: Lorum Ipsum
}
{
id: 4
locID: B
tStart: 17:51:00
tEnd: 17:56:00
name: the woman 2
text: Lorum Ipsum
}
{
id: 5
locID: A
tStart: 17:11:00
tEnd: 16:11:00
name: the man with the golden gun
text: Lorum Ipsum
}
{
id: 6
locID: C
tStart: 17:11:00
tEnd: 17:11:00
name: the woman with the dragon tattoo
text: Lorum Ipsum
}
{
id: 7
locID: A
tStart: 17:15:00
tEnd: 17:15:00
name: Jo
text: Lorum Ipsum
}
我想要的是只得到
{
id: 1
locID: A
tStart: 17:10:00
tEnd: 17:35:00
name: the man 45
text: Lorum Ipsum
}
{
id: 4
locID: B
tStart: 17:51:00
tEnd: 17:56:00
name: the woman 2
text: Lorum Ipsum
}
{
id: 5
locID: A
tStart: 17:11:00
tEnd: 16:11:00
name: the man with the golden gun
text: Lorum Ipsum
}
{
id: 6
locID: C
tStart: 17:11:00
tEnd: 17:11:00
name: the woman with the dragon tattoo
text: Lorum Ipsum
}
有人可以告诉我我需要做什么才能跳过剩下的行吗?
我目前的设置 returns 一切,Frank id:2
Frank id:3
the woman 2 id:4
.
谢谢 mickmackusa。
解法:{[^}]*姓名:[^}]*\bthe\b[^}]*\}
否定字符 类 [^}]
加快一切速度并避免被换行符卡住。 *
可能是贪心的,因为它们将在 name:
、the
和 }
.
停止
模式(Demo Link):
{[^}]*name:[^}]*\bthe\b[^}]*}
编辑(转义大括号版本):
\{[^}]*name:[^}]*\bthe\b[^}]*\}
我正在尝试创建一个正则表达式来筛选文本文件 (Notepad++) 中的信息,但前提是该字符的名称中包含 "the"。
我现在的表情:\{[\r\n]+id:(.\*?)+name:\s+(\bthe\b)(.*?)[\r\n]\}
{
id: 1
locID: A
tStart: 17:10:00
tEnd: 17:35:00
name: the man 45
text: Lorum Ipsum
}
{
id: 2
locID: A
tStart: 17:11:00
tEnd: 17:12:00
name: Frank
text: Lorum Ipsum
}
{
id: 3
locID: A
tStart: 17:11:00
tEnd: 17:14:00
name: Frank
text: Lorum Ipsum
}
{
id: 4
locID: B
tStart: 17:51:00
tEnd: 17:56:00
name: the woman 2
text: Lorum Ipsum
}
{
id: 5
locID: A
tStart: 17:11:00
tEnd: 16:11:00
name: the man with the golden gun
text: Lorum Ipsum
}
{
id: 6
locID: C
tStart: 17:11:00
tEnd: 17:11:00
name: the woman with the dragon tattoo
text: Lorum Ipsum
}
{
id: 7
locID: A
tStart: 17:15:00
tEnd: 17:15:00
name: Jo
text: Lorum Ipsum
}
我想要的是只得到
{
id: 1
locID: A
tStart: 17:10:00
tEnd: 17:35:00
name: the man 45
text: Lorum Ipsum
}
{
id: 4
locID: B
tStart: 17:51:00
tEnd: 17:56:00
name: the woman 2
text: Lorum Ipsum
}
{
id: 5
locID: A
tStart: 17:11:00
tEnd: 16:11:00
name: the man with the golden gun
text: Lorum Ipsum
}
{
id: 6
locID: C
tStart: 17:11:00
tEnd: 17:11:00
name: the woman with the dragon tattoo
text: Lorum Ipsum
}
有人可以告诉我我需要做什么才能跳过剩下的行吗?
我目前的设置 returns 一切,Frank id:2
Frank id:3
the woman 2 id:4
.
谢谢 mickmackusa。
解法:{[^}]*姓名:[^}]*\bthe\b[^}]*\}
否定字符 类 [^}]
加快一切速度并避免被换行符卡住。 *
可能是贪心的,因为它们将在 name:
、the
和 }
.
模式(Demo Link):
{[^}]*name:[^}]*\bthe\b[^}]*}
编辑(转义大括号版本):
\{[^}]*name:[^}]*\bthe\b[^}]*\}