Home > Blockchain >  Regex pattern matching last word in parentheses containing all parentheses
Regex pattern matching last word in parentheses containing all parentheses

Time:07-25

I need help matching these patterns all at once. I am using Google Sheets REGEXEXTRACT.

This is what I have so far:

\(. \)

This matches (Jake), (The LGS Regiment) (Bob), and (John (Wake)) from the examples below. I need to find a way to not include parentheses and match just what is inside the last parenthetical closure. Any regex wizards out there have any ideas?

The Liberated Guardsmen of Solemnace (The LGS Regiment) (Bob)
The Tribulation of St. Genevael (John (Wake))
Hive Fleet Oblivion (Jake)

I need to match:

Bob
John (Wake)
Jake

CodePudding user response:

try:

=ARRAYFORMULA(IFNA(REGEXEXTRACT(
 REGEXEXTRACT(REGEXEXTRACT(A1:A3, "\((. \))"), "(. )\)"), "\((. [a-z]$)"), 
 REGEXEXTRACT(REGEXEXTRACT(A1:A3, "\((. \))"), "(. )\)")))

enter image description here

  • Related