多正则匹配筛选及Google Sheets跨表提取最大日期需求
Hey there! Let's break down your Google Sheets needs and answer your regex question clearly:
To pull the latest (maximum) date from articles!F:F where the value in articles!B:B matches the corresponding statename in your MAIN SHEET, you'll want to use the MAXIFS function—it's perfect for returning a max value based on matching conditions.
Assuming the statename you're matching is in the same row of your MAIN SHEET (e.g., if your statename is in column A, row 26, and you want the result in P26), enter this formula in cell P26 of the MAIN SHEET:
=MAXIFS(articles!F:F, articles!B:B, A26)
Then drag the fill handle down from P26 to P38 to apply it to all your target rows.
If you want to handle cases where there's no matching statename (to avoid #N/A errors), wrap it in IFERROR:
=IFERROR(MAXIFS(articles!F:F, articles!B:B, A26), "")
Absolutely—Google Sheets does support multi-regex matching for filtering! Here are two common approaches:
Single REGEXMATCH with pipe-separated patterns: Use
|to separate multiple regex patterns within a singleREGEXMATCHcall. This works when you want to match any of the patterns:=REGEXMATCH(B1, "pattern1|pattern2|pattern3")For example, to match statenames starting with "U" or ending with "a":
=REGEXMATCH(B1, "^U|a$")OR with multiple REGEXMATCH functions: If you need more control over individual patterns (e.g., different case sensitivity or complex logic), combine multiple
REGEXMATCHcalls withOR:=OR(REGEXMATCH(B1, "pattern1"), REGEXMATCH(B1, "pattern2"), REGEXMATCH(B1, "pattern3"))
You can use these directly in a filter. For example, to filter the 'articles' sheet to rows where column B matches any of your regex patterns:
=FILTER(articles!A:F, REGEXMATCH(articles!B:B, "pattern1|pattern2"))
内容的提问来源于stack exchange,提问作者PTN

