89 lines
5.6 KiB
XML
89 lines
5.6 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<helpdocument version="1.0">
|
|
<!--
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
-->
|
|
|
|
<meta>
|
|
<topic id="textswriterguidesearch_regexpxml" indexer="include" status="PUBLISH">
|
|
<title xml-lang="en-US" id="tit">Using Regular Expressions in Text Searches</title>
|
|
<filename>/text/swriter/guide/search_regexp.xhp</filename>
|
|
</topic>
|
|
</meta>
|
|
|
|
<body>
|
|
<bookmark xml-lang="en-US" branch="index" id="bm_id3150099">
|
|
<bookmark_value>searching; with regular expressions</bookmark_value>
|
|
<bookmark_value>regular expressions;searching</bookmark_value>
|
|
<bookmark_value>examples for regular expressions</bookmark_value>
|
|
<bookmark_value>characters;finding all</bookmark_value>
|
|
<bookmark_value>invisible characters;finding</bookmark_value>
|
|
<bookmark_value>paragraph marks;searching</bookmark_value>
|
|
</bookmark>
|
|
<h1 id="hd_id3150099"><variable id="search_regexp"><link href="text/swriter/guide/search_regexp.xhp">Using Regular Expressions in Text Searches</link></variable></h1>
|
|
<paragraph xml-lang="en-US" id="par_id0509200916345516" role="paragraph">Regular expressions are special patterns used to find and manipulate text, helping you locate specific information within texts.</paragraph>
|
|
<note id="par_id421554926388821">Searching with regular expressions is different from searching with wildcards. %PRODUCTNAME Writer only supports searching with regular expressions.</note>
|
|
<paragraph xml-lang="en-US" id="par_id3155182" role="paragraph">You can use regular expressions when you find and replace text in a document. For example, "s.n" finds "sun" and "son".</paragraph>
|
|
<list type="ordered">
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3155907" role="listitem">Choose <item type="menuitem">Edit - Find & Replace</item>.</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id2142399" role="listitem">Click <item type="menuitem">More Options</item> to expand the dialog.</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3155861" role="listitem">Select the <item type="menuitem">Regular expressions</item> check box.</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3149843" role="listitem">In the <item type="menuitem">Find</item> box, type the search term and the regular expression(s) that you want to use in your search.</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3156113" role="listitem">Click <item type="menuitem">Find Next</item> or <item type="menuitem">Find All</item>.</paragraph>
|
|
</listitem>
|
|
</list>
|
|
<h2 id="hd_id3153401">Regular Expression Examples</h2>
|
|
<list type="ordered">
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3149641" role="listitem">The regular expression for a single character is a period (.).</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3149642" role="listitem">The regular expression for a word character \w, and \d for a decimal digit.</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3153136" role="listitem">The regular expression for zero or more occurrences of the previous character is an asterisk. For example: "123*" finds "12" "123", and "1233".</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3149609" role="listitem">The regular expression to search for zero or more occurrences of any character is a period and asterisk (.*).</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3153138" role="listitem">The regular expression for one or more occurrences of the previous character is a plus sign (+). For example: "\w+" finds any word, "\d+" any number.</paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id0509200916345545" role="listitem">The regular expression for a tab character is \t. More generally, \s stands for all kinds of "spaces", like non-breaking space, carriage return ... </paragraph>
|
|
</listitem>
|
|
<listitem>
|
|
<paragraph xml-lang="en-US" id="par_id3149854" role="listitem">The regular expression for the end of a paragraph is a dollar sign ($). The regular expression for the start of a paragraph is a caret and a period (^.). The regular expression for an empty paragraph is ^$.</paragraph>
|
|
</listitem>
|
|
</list>
|
|
<paragraph xml-lang="en-US" id="par_id3153414" role="note">A search using a regular expression will work only within one paragraph. That is, a \n will match a line break within a paragraph.</paragraph>
|
|
<section id="relatedtopics">
|
|
<embed href="text/shared/01/02100001.xhp#02100001"/>
|
|
<embed href="text/swriter/guide/removing_line_breaks.xhp#removing_line_breaks"/>
|
|
<embed href="text/scalc/guide/wildcards.xhp#wildcards_h1"/>
|
|
</section>
|
|
</body>
|
|
</helpdocument>
|