查找&在 Google 电子表格上用换行符替换逗号

发布于 2024-12-06 12:39:43 字数 136 浏览 0 评论 0原文

我一直在尝试找出如何用换行符替换逗号。我尝试过使用 (/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

段念尘 2024-12-13 12:39:43

如果您尝试使用 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
you will be presented with this dialog

安静 2024-12-13 12:39:43

如果我正确理解你想要获得类似的东西:

在此处输入图像描述

我发现的技巧是这样的:

  1. 插入一个表达式 =SUBSTITUTE(A3,",","")
  2. 然后编辑公式您刚刚键入,将光标放在最近的两个双引号之间: =SUBSTITUTE(A3,",","")
  3. 最后按 CTRL+ENTER。这是插入“换行”字符的方法。

If I properly understood you want to obtain something like that:

enter image description here

The trick I discovered is this one:

  1. you insert an expression as =SUBSTITUTE(A3,",","")
  2. then edit the formula you've just types, you placed the cursor in between the latest two double quotes: =SUBSTITUTE(A3,",","<PLACE CURSOR HERE>")
  3. and finally you press CTRL+ENTER. This is the way to insert a "new line" character.
杀お生予夺 2024-12-13 12:39:43

此回复并未具体回答原始问题,但我发现它是一个类似的用例,可能对其他人有帮助。如果您正在使用其他文本搜索换行符,并且希望替换保留换行符,则可以使用以下一种方法。

我的示例搜索换行符加空格,然后将其替换为新行。

查找:(\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)

风为裳 2024-12-13 12:39:43

使用上面提到的替代公式 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)".

扬花落满肩 2024-12-13 12:39:43

使用公式解析

=SPLIT(A14,CHAR(10))的示例

example using formula to parse

=SPLIT(A14,CHAR(10))

烂人 2024-12-13 12:39:43

要将所有“>”(大于)更改为“>\n”(大于后跟换行符),
我采取了这个三步曲折的方法。

  1. 将文本复制到 LibreOffice“文本文档”
  2. 编辑 =>查找&替换 // 快捷键:Ctrl + H
  3. 填写 3 个字段(下图中的 1~3 框),然后单击“全部替换”按钮。

输入图片此处描述

To change all ">"(greater than) to ">\n"(greater than followed by a newline),
I took this 3 step circuitous approach.

  1. Copy the text onto LibreOffice "Text document"
  2. Edit => Find & Replace // shortcut: Ctrl + H
  3. Fill out 3 fields(boxes 1~3 in the below figure) there and click "Replace All" button.

enter image description here

浮世清欢 2024-12-13 12:39:43

使用“使用正则表达式替换”选项。那么目标是 \n ,替换是 , (即逗号后跟空格)。

Use the "replace using regular expressions" option. Then the target is \n and the replacement is , (i.e., comma followed by space).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文