查找&在 Google 电子表格上用换行符替换逗号
我一直在尝试找出如何用换行符替换逗号。我尝试过使用 (/r/n/)
、char(10)
、Unicode 表示形式(现在不记得了),但它可以预见地取代了逗号无论我在另一个框中输入什么内容,都不会将其转换为换行符
I've been trying to figure out how to replace commas with line-breaks. I've tried using (/r/n/)
, char(10)
, the Unicode representation (can't remember now), but it rather predictably replaces the comma with whatever I type in the other box, not converting it to a line-break
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您尝试使用 Ctrl+F 来查找和替换,则不能。至少我不知道怎么做。
但如果你有一个单元格 A1 包含以下内容:“堆栈,溢出”
那么如果你在 A2 中输入它应该可以工作: =SUBSTITUTE(A1, ",", char(10))
https://support.google.com/docs/bin/static.py?hl=en&topic=25273&page=table.cs
然后您可以复制 A2 的内容并在A3中右键->选择性粘贴... ->仅值。
希望这对
2016 年 8 月更新 有所帮助
Google 电子表格现在支持使用 \n 搜索换行符,具体方法如下:
编辑->查找和替换
IF you are trying to use the Ctrl+F to find and replace well you can't. at least I dont know how.
but if you have a cell say A1 that contains the following : "stack,overflow"
then if you type this in A2 it should work: =SUBSTITUTE(A1, ",", char(10))
https://support.google.com/docs/bin/static.py?hl=en&topic=25273&page=table.cs
you can then copy the content of A2 and in A3 right click -> Paste Special... -> Values Only.
Hope this helps
UPDATE 2016-AUG
Google Spreadsheet now support searching for newline using \n here is how:
Edit -> Find and Replace
如果我正确理解你想要获得类似的东西:
我发现的技巧是这样的:
=SUBSTITUTE(A3,",","")
=SUBSTITUTE(A3,",","")
CTRL
+ENTER
。这是插入“换行”字符的方法。If I properly understood you want to obtain something like that:
The trick I discovered is this one:
=SUBSTITUTE(A3,",","")
=SUBSTITUTE(A3,",","<PLACE CURSOR HERE>")
CTRL
+ENTER
. This is the way to insert a "new line" character.此回复并未具体回答原始问题,但我发现它是一个类似的用例,可能对其他人有帮助。如果您正在使用其他文本搜索换行符,并且希望替换保留换行符,则可以使用以下一种方法。
我的示例搜索换行符加空格,然后将其替换为新行。
查找:
(\n)\s
替换:
$1
如果谷歌允许在替换字段中使用正则表达式,那就太好了,但是如果换行符是搜索参数并且需要包含在替换部分中。
注意:根据 Google 的文档,替换组仅适用于表格。 (截至2017年7月13日)
This response doesn't specifically answer the original question, but it is a similar use-case that I found which may help someone else. If you are searching for a newline character with other text and you want your replace to keep the newline character, here's one way you can do it.
My example searches for newline plus space and then replaces it with just a new line.
Find:
(\n)\s
Replace:
$1
It would be nice if google allowed regex in the replace field, but this might help someone if the newline character is part of the search parameters and needs to be included in the replace portion.
NOTE: Per Google's documentation, replace groups only work with Sheets. (as of July 13, 2017)
使用上面提到的替代公式 gmansour 在新的谷歌表格中有效。但是,执行“查找并替换”(CTRL H) 则不会。我尝试使用 char(10) 作为替换,但仅显示“char(10)”。
Using the substitute formula gmansour mentioned above works in the new google sheets. However, doing a Find and Replace (CTRL H) does not. I tried using char(10) as a replace and only shows "char(10)".
使用公式解析
=SPLIT(A14,CHAR(10))的示例
example using formula to parse
=SPLIT(A14,CHAR(10))
要将所有“>”(大于)更改为“>\n”(大于后跟换行符),
我采取了这个三步曲折的方法。
To change all ">"(greater than) to ">\n"(greater than followed by a newline),
I took this 3 step circuitous approach.
使用“使用正则表达式替换”选项。那么目标是
\n
,替换是,
(即逗号后跟空格)。Use the "replace using regular expressions" option. Then the target is
\n
and the replacement is,
(i.e., comma followed by space).