c# word中替换字符_如何在Microsoft Word中查找和替换特殊字符
c# word中替换字符
In addition to searching and replacing text, Word lets you search for special characters—tabs, indents, paragraph marks, and so on—and then replace them with other special characters. This can be handy for quick and easy changes which would typically take you a bit more time to do manually.
除了搜索和替换文本外,Word还允许您搜索特殊字符(制表符,缩进,段落标记等),然后将其替换为其他特殊字符。 快速方便地进行更改非常方便,通常需要您多花点时间进行手动操作。
什么时候搜索和替换特殊字符有用? (When Is Searching and Replacing Special Characters Useful?)
To understand when searching and replacing special characters may be useful, let’s look at some examples.
为了了解在搜索和替换特殊字符时可能有用的方法,我们来看一些示例。
- Let’s say there is a lengthy legal document that you need to edit. You have been asked to replace the word “section” with the section symbol. The section symbol is a pair of overlapping “S” characters and is often used in legal documents to reference a numbered section in a document. Your document is over 50 pages, and there are numerous references to various sections throughout. You can easily replace the word “section” with the section symbol using search and replace.
假设您需要编辑一份冗长的法律文件。 您被要求用节符号代替“节”。 章节符号是一对重叠的“ S”字符,在法律文档中经常用于引用文档中带编号的章节。 您的文档超过50页,并且在整个章节中都有大量引用。 您可以使用搜索和替换功能轻松地用部分符号替换“部分”一词。
- You have just finished writing a draft of your first novel, and it includes a variety of hyphenated words. You need to keep the hyphenated words together by replacing the regular hyphen with a non-breaking hyphen. You start replacing the symbol manually but stop yourself after a few attempts. You know there has to be an easier way. There is! Just use Find and Replace to do the job for you.
您刚刚写完了第一本小说的草稿,其中包括各种连字符。 您需要通过使用不间断的连字符替换常规的连字符来将连字符连在一起。 您开始手动替换符号,但经过几次尝试后却停止了操作。 您知道必须有一种更简单的方法。 有! 只需使用“查找并替换”即可为您完成工作。
- A colleague has resigned, and you have been assigned the task of editing a report that the colleague worked on before he left. The report is well written, but there is inconsistent paragraph spacing throughout. After clicking Show/Hide, you discover that in some cases, there are two paragraph marks instead of one. One way to correct the paragraph spacing would be to press the Delete key every time you see an extra paragraph mark. But there’s a faster way–just search for every occurrence of two paragraph marks and replace it with one paragraph mark.
一位同事辞职了,您被分配了编辑一份报告的任务,该报告是在他离开之前编辑的。 该报告写得很好,但整个段落的段落间距不一致。 单击“显示/隐藏”后,您发现在某些情况下,有两个段落标记而不是一个。 纠正段落间距的一种方法是,每当您看到一个额外的段落标记时,按Delete键。 但是,有一种更快的方法-只需搜索每次出现的两个段落标记并将其替换为一个段落标记。
There are too many special characters to detail all of them, but let’s take a look at a few general examples of how searching and replacing those characters works.
有太多特殊字符无法详细说明所有这些字符,但让我们看一些有关如何搜索和替换这些字符的一般示例。
示例1:用特殊字符替换文本 (Example One: Replace Text with a Special Character)
Let’s say your document looks something like this:
假设您的文档看起来像这样:
Note: If you don’t see the special characters in your document, you can turn them on by clicking the Show/Hide button on the Ribbon. Its icon looks like the paragraph symbol.
注意:如果在文档中看不到特殊字符,可以通过单击功能区上的“显示/隐藏”按钮将其打开。 其图标看起来像段落符号。
You need to replace every occurrence of the word “Section” with a section symbol. Switch over to the “Home” tab on Word’s Ribbon and then click “Replace.” Alternatively, you can press Ctrl+H.
您需要将每次出现的“节”替换为节符号。 切换到Word功能区上的“主页”选项卡,然后单击“替换”。 或者,您可以按Ctrl + H。
Type the word “Section” into the “Find What” box and then click the “More >>” button to expand the Find and Replace options.
在“查找内容”框中键入单词“ Section”,然后单击“更多>>”按钮以展开“查找和替换”选项。
Click in the “Replace With” box to put your insertion point there and then click the “Special” button.
单击“替换为”框,将插入点放在此处,然后单击“特殊”按钮。
Click “Section Character” from the dropdown list.
从下拉列表中单击“部分字符”。
Notice that the “Replace With” box now contains the text “^%”—this is Word’s code for that section symbol. Click the “Replace All” button. In this example, 16 replacements were made. Click the “OK” button and then close the Find and Replace window.
注意,“替换为”框现在包含文本“ ^%”,这是该节符号的Word代码。 点击“全部替换”按钮。 在此示例中,进行了16次替换。 单击“确定”按钮,然后关闭“查找和替换”窗口。
All occurrences of the word “Section” have now been replaced with the section character.
现在,所有出现的“ Section”一词都已替换为section字符。
示例二:用不间断的连字符替换常规的连字符 (Example Two: Replace a Regular Hyphen with a Non-Breaking Hyphen)
For this next example, notice there are quite a few hyphenated words in our sample paragraph, including three occurrences where the hyphenated words are separated on different lines. Let’s replace all the regular hyphens with non-breaking hyphens so that doesn’t happen.
对于下一个示例,请注意在我们的示例段落中有很多连字符,包括三个出现的连字符在不同行上分开的情况。 让我们用不间断的连字符替换所有常规的连字符,以免发生这种情况。
On the “Home” tab, click “Replace” or just press Ctrl+H.
在“主页”选项卡上,单击“替换”,或仅按Ctrl + H。
In the “Find What” box, delete any existing text or characters and then type a single hyphen character. Click the “More >>” button if needed to expand the Find and Replace options.
在“查找内容”框中,删除任何现有的文本或字符,然后键入一个连字符。 如果需要,请单击“更多>>”按钮以展开“查找和替换”选项。
Click in the “Replace With” box to put your insertion point there. Delete any existing text or characters and then click the “Special” button.
单击“替换为”框,将您的插入点放在此处。 删除任何现有的文本或字符,然后单击“特殊”按钮。
Click “Nonbreaking Hyphen” from the dropdown list.
从下拉列表中单击“不间断的连字符”。
Notice that Word’s code for the nonbreaking hyphen—“^~”— has now been added to the “Replace With” box. Click the “Replace All” button. In this example, 11 replacements were made. Click the “OK” button and then close the Find and Replace window.
请注意,Word的不间断连字符-“ ^〜”-现在已添加到“替换为”框中。 点击“全部替换”按钮。 在此示例中,进行了11次替换。 单击“确定”按钮,然后关闭“查找和替换”窗口。
Word has replaced all hyphens with nonbreaking hyphens. Notice the hyphenated words on the right margin are no longer separated.
Word已将所有连字符替换为不间断的连字符。 请注意,右边距处的连字符不再分开。
示例三:用一个段落标记替换两个段落标记 (Example Three: Replacing Two Paragraph Marks with One Paragraph Mark)
In this example, we want to replace any double paragraph marks with a single paragraph mark, removing the extra spacing between paragraphs.
在此示例中,我们希望将任何双段标记替换为单个段标记,从而消除段之间的多余间距。
On the “Home” tab, click the “Replace” button. Alternatively, you can press Ctrl+H.
在“主页”选项卡上,单击“替换”按钮。 或者,您可以按Ctrl + H。
Click in the “Find What” box and then delete any existing text or characters. Click the “More>>” button to open up the additional options, click the “Special” button, and then click the “Paragraph Mark” option from the dropdown list.
单击“查找内容”框,然后删除任何现有的文本或字符。 单击“更多>>”按钮以打开其他选项,单击“特殊”按钮,然后从下拉列表中单击“段落标记”选项。
Notice that Word’s code for a paragraph mark (“^v”) has been inserted into the “Find What” box. Click the “Special” button again and then click “Paragraph Mark” again from the dropdown list to place a second paragraph mark there. (Note that you could also just type “^v^v” into the box yourself if you’re already familiar with the codes.)
请注意,段落标记(“ ^ v”)的Word代码已插入“查找内容”框中。 再次单击“特殊”按钮,然后再次从下拉列表中单击“段落标记”以在其中放置第二个段落标记。 (请注意,如果您已经熟悉代码,也可以自己在框中输入“ ^ v ^ v”。)
There are now two paragraph marks in the Find what box. Click in the “Replace With” box, delete any existing text or characters, and then click the “Special” button. On the dropdown menu, choose “Paragraph Mark.”
现在,在“查找内容”框中有两个段落标记。 单击“替换为”框中,删除任何现有的文本或字符,然后单击“特殊”按钮。 在下拉菜单上,选择“段落标记”。
For the final step, click the “Replace All” button. In this example, Word made eight replacements. Click the “OK” button and then close the Find and Replace window.
对于最后一步,单击“全部替换”按钮。 在此示例中,Word进行了八次替换。 单击“确定”按钮,然后关闭“查找和替换”窗口。
All occurrences of two paragraph marks have been replaced with one paragraph mark.
所有出现的两个段落标记都已替换为一个段落标记。
As you can see, using Find and Replace can save you lots of time when replacing special characters in your documents. And we’ve just scratched the surface here. There are more special characters waiting on that menu for you to explore.
如您所见,当替换文档中的特殊字符时,使用“查找并替换”可以节省大量时间。 我们只是在这里刮了一下表面。 该菜单上还有更多特殊字符供您浏览。
翻译自: https://www.howtogeek.com/364843/how-to-find-and-replace-special-characters-in-microsoft-word/
c# word中替换字符
原文地址: https://blog.csdn.net/culinluo3322/article/details/108706972
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
相关文章