英文:
Extract value in last bracket
问题
你可以尝试以下公式来从Google表格的列中提取国家,即最后括号内的值:
=REGEXEXTRACT(A2, "\((.*)\)$")
这个公式应该可以得到你期望的输出:Brazil、UK 和 Spain。
英文:
How could I extract the country from a Google Sheet column? i.e. the value in the final bracket
Paper (Brazil)
Table (J) (UK)
Pen (Spain)
Expected Output:
Brazil
UK
Spain
I tried:
=REGEXEXTRACT(A2,"\((.*)\)$")
答案1
得分: 1
尝试嵌套使用 REGEXEXTRACT()
。
=REGEXEXTRACT(REGEXEXTRACT(A2, ".+\s(.+)"), "\((.*)\)$")
英文:
Try nested REGEXEXTRACT()
.
=REGEXEXTRACT(REGEXEXTRACT(A2,".+\s(.+)") ,"\((.*)\)$")
答案2
得分: 0
=索引(ifna(regexextract(A2:A,".\s((\w+)\W?)")))
答案3
得分: 0
=REGEXEXTRACT(A1,"(\w+)\W+$")
=INDEX(IFERROR(REGEXEXTRACT(A1:A6,"(\w+)\W+$")))
(请根据您的范围和语言环境调整公式)
\w:匹配任何字母、数字或下划线
\W:匹配除字母、数字或下划线之外的任何字符
+:匹配一个或多个连续字符
所使用的函数:
INDEX
IFERROR
REGEXEXTRACT
英文:
For a single cell you can use:
=REGEXEXTRACT(A1,"(\w+)\W+$")
For a whole range, this one:
=INDEX(IFERROR(REGEXEXTRACT(A1:A6,"(\w+)\W+$")))
(Do adjust the formulae according to your ranges and locale)
\w
Matches any letter, digit or underscore\W
Matches anything other than a letter, digit or underscore.+
Matches one or more consecutive characters
Functions used:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论