问题描述
Google 电子表格中的矩阵管理功能非常方便,并且与处理 REGEXMATCH 和 REGEXEXTRACT 等正则表达式的函数相结合,使其特别有用.
The matrix management feature in Google Spreadsheets is convenient and combined with functions that handle regular expressions like REGEXMATCH and REGEXEXTRACT, among others, makes it especially useful.
我有一个案例,我不知道什么原因没有给出预期的结果.这是我正在尝试做的:
I have a case in which I do not know what is due that does not give the expected result. Here's what I'm trying to do:
电子表格设置
区域设置:墨西哥,使用 .
(点)作为小数点分隔符.
Spreadsheet Settings
Regional Settings: Mexico, use .
(dot) as decimal separator.
进入
A1:abcde
公式
B1:=ArrayFormula(REGEXEXTRACT(A1,{".{1}",".{2}"}))
预期结果
B1:a
B2:ab
获得的结果
B1:a
B2:
已知的解决方法=ArrayFormula(TRANSPOSE(REGEXEXTRACT(A1,{".{1}";".{2}"})))
此问题也已发布在西班牙网站上 -> https://es.stackoverflow.com/q/55704/65
This question also has being posted on the Spanish site -> https://es.stackoverflow.com/q/55704/65
推荐答案
在 REGEXEXTRACT 数组今天神秘停止工作(Google 文档帮助论坛):
Quoting Jean-Pierre Verhulst on a similar case in REGEXEXTRACT Array Mysteriously Stopped Working Today (Google Docs Help Forum):
团队很清楚这个问题,应该很快就会修复.
巧合的是,它于 2017 年 1 月 4 日发布,同一天 AdamL 修改了他对 ARRAYFORMULA() 不适用于 SPLIT(),说明:
Coincidentally, it was published Jan 4th, 2017, the same date AdamL modified his answer to ARRAYFORMULA() does not work with SPLIT(), explaining that:
REGEXEXTRACT 似乎不再支持第二个参数的数组.
我们可以得出结论,ArrayFormula 中的这种行为是由于 Google 表格中的修改,允许在数组公式中使用 SPLIT,结果是 REGEXEXTRACT 不接受多列作为正则表达式中的输入.
We can conclude that this behaviour in ArrayFormula is due to a modification in Google Sheets, allowing SPLIT in array formulas, with the consequence of REGEXEXTRACT not accepting multiple columns as input in the regex.
这可能是因为 REGEXEXTRACT,在正则表达式中有多个捕获组,产生一个水平数组,每个组一个单元格.有一个数组作为参数,行为可能是未定义的,但这在我这边是明显的争论.
This is probably because REGEXEXTRACT, with multiple capture groups in the regular expression, yields an horizontal array, one cell for each group. Having an array as argument, the behaviour may be undefined, but that is plain argumentative on my side.
这篇关于为什么 REGEXEXTRACT 在预期返回 1 行多列的数组时返回单个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!