admin管理员组文章数量:1318129
I need to remove the space before the new line, within the cell. I know TRIM should work for this, but I believe it only deletes the very last space of the string.
So I probably need to replace space+CHAR(10) into CHAR(10) only. But I'm not sure which formula is best for this. Any ideas?
I need to remove the space before the new line, within the cell. I know TRIM should work for this, but I believe it only deletes the very last space of the string.
So I probably need to replace space+CHAR(10) into CHAR(10) only. But I'm not sure which formula is best for this. Any ideas?
Share Improve this question edited Jan 30 at 11:00 jonrsharpe 122k30 gold badges267 silver badges474 bronze badges asked Jan 30 at 10:53 AnneAnne 191 silver badge1 bronze badge2 Answers
Reset to default 2You can try these Formulas using REGEXREPLACE:
=REGEXREPLACE(A1, "\s+\n", CHAR(10))
Or
=REGEXREPLACE(A1, "\s+($|\n)", "$1")
Also, you can try using REDUCE:
=REDUCE(,SPLIT(A1, CHAR(10)), LAMBDA(a,c, JOIN(REGEXREPLACE(c,"\s[^ ]*$",""),a,CHAR(10))))
Use split()
to break text into parts at newlines, trim()
to remove spaces at the start and end of lines and to replace repeated spaces within lines, and finally join()
to put the parts back together, like this:
=join(char(10), sort(trim(split(A1, char(10)))))
The sort()
function is only used to array enable the trim()
and doesn't actually sort anything in this context.
See split(), trim() and join().
本文标签: google sheetsRemove space after line before new lineStack Overflow
版权声明:本文标题:google sheets - Remove space after line before new line - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741972394a2407919.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论