.+(?<![a-z]\s)([A-Z](?=[a-z'-]+)[a-z'-]+)(?!\s).+\((.+)\).+(?<![a-z]\s)([A-Z](?=[a-z'-]+)[a-z'-]+)(?!\s).+\((.+)\)
案例:
[Nisei](slightly scratched) [Ocellaris](unconcious)
L: 1799 Ocellaris: (slightly scratched) vs. N'isei: (mildly wounded)
[Nisei](slightly scratched) [Zealot Warrior](perfect condition)
L: 1799 Ocellaris: (slightly scratched) vs. zealot warrior: (mildly wounded)
[fire dragon](slightly scratched) [Zealot Warrior](perfect condition)
[King Jheric](slightly scratched) [Zealot Warrior](perfect condition)
1 和 2 应该匹配,但 3 和 6 不应该匹配。他们在 () 之前的部分中有两个词。我试图做一个 (?!\s) 或 (?!\b) 来忽略下一个单词,但它似乎只回溯到前一个字符并忽略它。
结果
Case 1:
1: [1,6] Nisei
2: [8,26] slightly scratched
3: [29,38] Ocellaris
4: [40,57] unconcious
Case 2:
1: [8,17] Ocellaris
2: [20,38] slightly scratched
3: [44,50] N'isei
4: [53,67] mildly wounded
Case 3:
1: [1,6] Nisei
2: [8,26] slightly scratched
3: [29,34] Zealo
4: [45,62] perfect condition
Case 4:
No Match
Case 5:
No Match
Case 6:
1: [1,4] Kin
2: [14,32] slightly scratched
3: [35,40] Zealo
4: [51,68] perfect condition
更新:
一般模式是
Person or NPC (condition) Person or NPC (condition)
人只能有一个大写的名字,而一个 NPC 可以有两个不同大小写的名字......国王 Jheric vs wolfen berserker vs zealot Warriors。
它必须模糊的原因是它必须匹配模式,例如
Me:(condition) v Target:(condition)
Reply:Some Person L:1200 King Jheric:(condition) vs. Target:(condition)
[Me] -> (condition) [wolfen berserker] -> (condition)
Lag: 1200 [zealot warrior](condition) vs. [King Jheric](condition)
更新 2:
(?<![a-z]|(?:\d+))([A-Z](?=[a-z'-]+)(?!.*\s\d+)[a-z'-]+).+\((.+)\).+(?<![a-z]|(?:\d+))([A-Z](?=[a-z'-]+)(?!.*\s\d+)[a-z'-]+).+\((.+)\)
这解决了上面列出的所有情况,包括原始情况,除了第一个或第二个“事物”有两个单词并且其中至少一个是大写的。