问题描述
Google Spreadsheets中的矩阵管理功能非常方便,并且与处理正则表达式(例如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
Entry
A1: abcde
公式
B1:=ArrayFormula(REGEXEXTRACT(A1,{".{1}",".{2}"}))
Formula
B1: =ArrayFormula(REGEXEXTRACT(A1,{".{1}",".{2}"}))
预期结果
B1:a
B2:ab
Expected result
B1: a
B2: ab
获得的结果
B1:a
B2:
Obtained result
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 修改了他对,解释说:
Coincidentally, it was published Jan 4th, 2017, the same date AdamL modified his answer to ARRAYFORMULA() does not work with SPLIT(), explaining that:
我们可以得出结论, 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.
这篇关于为什么当期望返回1行多列的数组时,REGEXEXTRACT返回单个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!