如何在工作表中使用正则表达式对以字母开头的所有新行进行编号(在单元格中)?

How do I use regex in sheets to number (in cell) everything new line that starts with Letters?

我的目标是得到这样的东西 goal. For every new line after the 1st one if it doesn't start with a ">" I want it to be numbered (starting from nr. 1 on), as for the lines that start with ">" - to just return those without numbering them. I've tried to insert strings with the numbers See here,问题是我不知道我可能有多少行不是以“>”开头的,如果这些行与其他行插入那些 - 所以我不能像我那样将字符串真正“硬编码”到公式中。任何解决方案?谢谢。

尝试:

=ARRAYFORMULA(TEXTJOIN(CHAR(10), 1, IF(REGEXMATCH(""&
 SPLIT(A2, CHAR(10)), "^>.*"), 
 SPLIT(A2, CHAR(10)), TRANSPOSE(MMULT(TRANSPOSE(TRANSPOSE((SEQUENCE(1, COLUMNS(
 SPLIT(A2, CHAR(10))))<=SEQUENCE(COLUMNS(
 SPLIT(A2, CHAR(10)))))*NOT(REGEXMATCH(
 SPLIT(A2, CHAR(10)), "^>.+")))), TRANSPOSE(SIGN(NOT(REGEXMATCH(
 SPLIT(A2, CHAR(10)), "^>.+"))))))&". "&
 SPLIT(A2, CHAR(10)))))