xref: /trunk/main/helpcontent2/source/text/shared/01/02100001.xhp (revision 4fd23d01256f61259ae75e149e713e494a0f0033)
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--***********************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements.  See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership.  The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License.  You may obtain a copy of the License at
12 *
13 *   http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied.  See the License for the
19 * specific language governing permissions and limitations
20 * under the License.
21 *
22 ***********************************************************-->
23
24<helpdocument version="1.0">
25<meta>
26<topic id="textshared0102100001xml" indexer="include" status="PUBLISH">
27<title xml-lang="en-US" id="tit">List of Regular Expressions</title>
28<filename>/text/shared/01/02100001.xhp</filename>
29</topic>
30</meta>
31<body>
32<bookmark xml-lang="en-US" branch="index" id="bm_id3146765">
33<bookmark_value>regular expressions; list of</bookmark_value>
34<bookmark_value>lists;regular expressions</bookmark_value>
35<bookmark_value>replacing;tab stops (regular expressions)</bookmark_value>
36<bookmark_value>tab stops;regular expressions</bookmark_value>
37<bookmark_value>concatenation, see ampersand symbol</bookmark_value>
38<bookmark_value>ampersand symbol, see also operators</bookmark_value>
39</bookmark><comment>mw added "replacing;" and "tab stops;"</comment>
40<paragraph xml-lang="en-US" id="hd_id3146765" role="heading" level="1" l10n="U"><variable id="02100001"><link href="text/shared/01/02100001.xhp">List of Regular Expressions</link>
41</variable></paragraph>
42<table id="tbl_id3149517">
43<tablerow>
44<tablecell>
45<paragraph xml-lang="en-US" id="par_id3149741" role="tablehead" l10n="U">Character</paragraph>
46</tablecell>
47<tablecell>
48<paragraph xml-lang="en-US" id="par_id3155577" role="tablehead" l10n="U">Result/Use</paragraph>
49</tablecell>
50</tablerow>
51<tablerow>
52<tablecell>
53<paragraph xml-lang="en-US" id="par_id6600543" role="tablecontent" l10n="NEW">Any character</paragraph>
54</tablecell>
55<tablecell>
56<paragraph xml-lang="en-US" id="par_id9824518.00000001" role="tablecontent" l10n="CHG">Represents the given character unless otherwise specified.</paragraph>
57</tablecell>
58</tablerow>
59<tablerow>
60<tablecell>
61<paragraph xml-lang="en-US" id="par_id3152427" role="tablecontent" l10n="U">.</paragraph>
62</tablecell>
63<tablecell>
64<paragraph xml-lang="en-US" id="par_id3149031" role="tablecontent" l10n="CHG">Represents any single character except for a line break or paragraph break. For example, the search term "sh.rt" returns both "shirt" and "short".</paragraph>
65</tablecell>
66</tablerow>
67<tablerow>
68<tablecell>
69<paragraph xml-lang="en-US" id="par_id3154682" role="tablecontent" l10n="CHG">^</paragraph>
70</tablecell>
71<tablecell>
72<paragraph xml-lang="en-US" id="par_id3155351" role="tablecontent" l10n="CHG">Only finds the search term if the term is at the beginning of a paragraph. Special objects such as empty fields or character-anchored frames, at the beginning of a paragraph are ignored. Example: "^Peter".</paragraph>
73</tablecell>
74</tablerow>
75<tablerow>
76<tablecell>
77<paragraph xml-lang="en-US" id="par_id3159194" role="tablecontent" l10n="CHG">$</paragraph>
78</tablecell>
79<tablecell>
80<paragraph xml-lang="en-US" id="par_id3152542" role="tablecontent" l10n="CHG">Only finds the search term if the term appears at the end of a paragraph. Special objects such as empty fields or character-anchored frames at the end of a paragraph are ignored. Example: "Peter$".</paragraph>
81</tablecell>
82</tablerow>
83<tablerow>
84<tablecell>
85<paragraph xml-lang="en-US" id="par_id3156414" role="tablecontent" l10n="U">*</paragraph>
86</tablecell>
87<tablecell>
88<paragraph xml-lang="en-US" id="par_id3155555" role="tablecontent" l10n="CHG">Finds zero or more of the characters in front of the "*". For example, "Ab*c" finds "Ac", "Abc", "Abbc", "Abbbc", and so on.</paragraph>
89</tablecell>
90</tablerow>
91<tablerow>
92<tablecell>
93<paragraph xml-lang="en-US" id="par_id3147399" role="tablecontent" l10n="U">+</paragraph>
94</tablecell>
95<tablecell>
96<paragraph xml-lang="en-US" id="par_id3157958" role="tablecontent" l10n="CHG">Finds one or more of the characters in front of the "+". For example, "AX.+4" finds "AXx4", but not "AX4".</paragraph>
97<paragraph xml-lang="en-US" id="par_id3145313" role="tablecontent" l10n="U">The longest possible string that matches this search pattern in a paragraph is always found. If the paragraph contains the string "AX 4 AX4", the entire passage is highlighted.</paragraph>
98</tablecell>
99</tablerow>
100<tablerow>
101<tablecell>
102<paragraph xml-lang="en-US" id="par_id3143267" role="tablecontent" l10n="U">?</paragraph>
103</tablecell>
104<tablecell>
105<paragraph xml-lang="en-US" id="par_id3153684" role="tablecontent" l10n="CHG">Finds zero or one of the characters in front of the "?". For example, "Texts?" finds "Text" and "Texts" and "x(ab|c)?y" finds "xy", "xaby", or "xcy".</paragraph>
106</tablecell>
107</tablerow>
108<tablerow>
109<tablecell>
110<paragraph xml-lang="en-US" id="par_id3166410" role="tablecontent" l10n="U">\</paragraph>
111</tablecell>
112<tablecell>
113<paragraph xml-lang="en-US" id="par_id3147209" role="tablecontent" l10n="CHG">Search interprets the special character that follows the "\" as a normal character and not as a regular expression (except for the combinations \n, \t, \&gt;, and \&lt;). For example, "tree\." finds "tree.", not "treed" or "trees".</paragraph>
114</tablecell>
115</tablerow>
116<tablerow>
117<tablecell>
118<paragraph xml-lang="en-US" id="par_id3152945" role="tablecontent" l10n="U">\n</paragraph>
119</tablecell>
120<tablecell>
121<paragraph xml-lang="en-US" id="par_id3153700" role="tablecontent" l10n="CHG">Represents a line break that was inserted with the Shift+Enter key combination. To change a line break into a paragraph break, enter <emph>\n</emph> in the <emph>Search for</emph> and <emph>Replace with</emph> boxes, and then perform a search and replace.</paragraph>
122<paragraph xml-lang="en-US" id="par_id9262672" role="tablecontent" l10n="NEW">\n in the <emph>Search for</emph> text box stands for a line break that was inserted with the Shift+Enter key combination.</paragraph>
123<paragraph xml-lang="en-US" id="par_id2366100" role="tablecontent" l10n="NEW">\n in the <emph>Replace with</emph> text box stands for a paragraph break that can be entered with the Enter or Return key.</paragraph>
124</tablecell>
125</tablerow>
126<tablerow>
127<tablecell>
128<paragraph xml-lang="en-US" id="par_id3153258" role="tablecontent" l10n="U">\t</paragraph>
129</tablecell>
130<tablecell>
131<paragraph xml-lang="en-US" id="par_id3157809" role="tablecontent" l10n="CHG">Represents a tab. You can also use this expression in the <emph>Replace with</emph> box.</paragraph>
132</tablecell>
133</tablerow>
134<tablerow>
135<tablecell>
136<paragraph xml-lang="en-US" id="par_id3150670" role="tablecontent" l10n="U">\b</paragraph>
137</tablecell>
138<tablecell>
139<paragraph xml-lang="en-US" id="par_id3153666" role="tablecontent" l10n="CHG">Match a word boundary. For example, "\bbook" finds "bookmark" but not "checkbook" whereas "book\b" finds "checkbook" but not "bookmark". The discrete word "book" is found by both search terms.</paragraph>
140</tablecell>
141</tablerow>
142<tablerow>
143<tablecell>
144<paragraph xml-lang="en-US" id="par_id3149576" role="tablecontent" l10n="U">^$</paragraph>
145</tablecell>
146<tablecell>
147<paragraph xml-lang="en-US" id="par_id3151245" role="tablecontent" l10n="CHG">Finds an empty paragraph.</paragraph>
148</tablecell>
149</tablerow>
150<tablerow>
151<tablecell>
152<paragraph xml-lang="en-US" id="par_id3148550" role="tablecontent" l10n="U">^.</paragraph>
153</tablecell>
154<tablecell>
155<paragraph xml-lang="en-US" id="par_id3159413" role="tablecontent" l10n="CHG">Finds the first character of a paragraph.</paragraph>
156</tablecell>
157</tablerow>
158<tablerow>
159<tablecell>
160<paragraph xml-lang="en-US" id="par_id3147282" role="tablecontent" l10n="CHG">&amp; or $0</paragraph>
161</tablecell>
162<tablecell>
163<paragraph xml-lang="en-US" id="par_id3153961" role="tablecontent" l10n="CHG">Adds the string that was found by the search criteria in the <emph>Search for</emph> box to the term in the <emph>Replace with</emph> box when you make a replacement.</paragraph>
164<paragraph xml-lang="en-US" id="par_id3149650" role="tablecontent" l10n="CHG">For example, if you enter "window" in the <emph>Search for</emph> box and "&amp;frame" in the <emph>Replace with</emph> box, the word "window" is replaced with "windowframe".</paragraph>
165<paragraph xml-lang="en-US" id="par_id3150543" role="tablecontent" l10n="CHG">You can also enter an "&amp;" in the <emph>Replace with</emph> box to modify the <emph>Attributes</emph> or the <emph>Format</emph> of the string found by the search criteria.</paragraph>
166</tablecell>
167</tablerow>
168<tablerow>
169<tablecell>
170<paragraph xml-lang="en-US" id="par_id3145419" role="tablecontent" l10n="U">[abc123]</paragraph>
171</tablecell>
172<tablecell>
173<paragraph xml-lang="en-US" id="par_id3154630" role="tablecontent" l10n="CHG">Represents one of the characters that are between the brackets.</paragraph>
174</tablecell>
175</tablerow>
176<tablerow>
177<tablecell>
178<paragraph xml-lang="en-US" id="par_id3156293" role="tablecontent" l10n="U">[a-e]</paragraph>
179</tablecell>
180<tablecell>
181<paragraph xml-lang="en-US" id="par_id3149167" role="tablecontent" l10n="CHG">Represents any of the characters that are between a and e, including both start and end characters</paragraph>
182<paragraph xml-lang="en-US" id="par_id100520090232005" role="tablecontent" l10n="NEW">The characters are ordered by their code numbers.</paragraph>
183</tablecell>
184</tablerow>
185<tablerow>
186<tablecell>
187<paragraph xml-lang="en-US" id="par_id3155994" role="tablecontent" l10n="U">[a-eh-x]</paragraph>
188</tablecell>
189<tablecell>
190<paragraph xml-lang="en-US" id="par_id3148676" role="tablecontent" l10n="CHG">Represents any of the characters that are between a-e and h-x.</paragraph>
191</tablecell>
192</tablerow>
193<tablerow>
194<tablecell>
195<paragraph xml-lang="en-US" id="par_id3145318" role="tablecontent" l10n="U">[^a-s]</paragraph>
196</tablecell>
197<tablecell>
198<paragraph xml-lang="en-US" id="par_id3153351" role="tablecontent" l10n="CHG">Represents everything that is not between a and s.</paragraph>
199</tablecell>
200</tablerow>
201<tablerow>
202<tablecell>
203<paragraph xml-lang="en-US" id="par_id3156543" role="tablecontent" l10n="U">\xXXXX</paragraph>
204</tablecell>
205<tablecell>
206<paragraph xml-lang="en-US" id="par_id3153768" role="tablecontent" l10n="U">Represents a special character based on its four-digit hexadecimal code (XXXX).</paragraph>
207<paragraph xml-lang="en-US" id="par_id3159252" role="tablecontent" l10n="U">The code for the special character depends on the font used. You can view the codes by choosing <emph>Insert - Special Character</emph>.</paragraph>
208</tablecell>
209</tablerow>
210<tablerow>
211<tablecell>
212<paragraph xml-lang="en-US" id="par_id3153951" role="tablecontent" l10n="U">|</paragraph>
213</tablecell>
214<tablecell>
215<paragraph xml-lang="en-US" id="par_id3154985" role="tablecontent" l10n="CHG">Finds the terms that occur before the "|" and also finds the terms that occur after the "|". For example, "this|that" finds "this" and "that".</paragraph>
216</tablecell>
217</tablerow>
218<tablerow>
219<tablecell>
220<paragraph xml-lang="en-US" id="par_id3147376" role="tablecontent" l10n="U">{2}</paragraph>
221</tablecell>
222<tablecell>
223<paragraph xml-lang="en-US" id="par_id3150103" role="tablecontent" l10n="U">Defines the number of times that the character in front of the opening bracket occurs. For example, "tre{2}" finds and selects "tree".</paragraph>
224</tablecell>
225</tablerow>
226<tablerow>
227<tablecell>
228<paragraph xml-lang="en-US" id="par_id3151289" role="tablecontent" l10n="U">{1,2}</paragraph>
229</tablecell>
230<tablecell>
231<paragraph xml-lang="en-US" id="par_id3147317" role="tablecontent" l10n="CHG">Defines the minimum and maximum number of times that the character in front of the opening bracket can occur. For example, "tre{1,2}" finds and selects "tre" and "tree".</paragraph>
232</tablecell>
233</tablerow>
234<tablerow>
235<tablecell>
236<paragraph xml-lang="en-US" id="par_id4870754" role="tablecontent" l10n="NEW">{1,}</paragraph>
237</tablecell>
238<tablecell>
239<paragraph xml-lang="en-US" id="par_id843836" role="tablecontent" l10n="NEW">Defines the minimum number of times that the character in front of the opening bracket can occur. For example, "tre{2,}" finds "tree", "treee", and "treeeee".</paragraph>
240</tablecell>
241</tablerow>
242<tablerow>
243<tablecell>
244<paragraph xml-lang="en-US" id="par_id3148616" role="tablecontent" l10n="U">( )</paragraph>
245</tablecell>
246<tablecell>
247<paragraph xml-lang="en-US" id="par_id2701803" role="tablecontent" l10n="NEW">In the <emph>Search for</emph> box:</paragraph>
248<paragraph xml-lang="en-US" id="par_id3153573" role="tablecontent" l10n="CHG">Defines the characters inside the parentheses as a reference. You can then refer to the first reference in the current expression with "\1", to the second reference with "\2", and so on.</paragraph>
249<paragraph xml-lang="en-US" id="par_id3156061" role="tablecontent" l10n="U">For example, if your text contains the number 13487889 and you search using the regular expression (8)7\1\1, "8788" is found.</paragraph>
250<paragraph xml-lang="en-US" id="par_id2367931" role="tablecontent" l10n="NEW">You can also use () to group terms, for example, "a(bc)?d" finds "ad" or "abcd".</paragraph>
251<paragraph xml-lang="en-US" id="par_id9200109" role="tablecontent" l10n="NEW">In the <emph>Replace with</emph> box:<comment>i83322</comment></paragraph>
252<paragraph xml-lang="en-US" id="par_id5766472" role="tablecontent" l10n="NEW">Use $ (dollar) instead of \ (backslash) to replace references. Use $0 to replace the whole found string.</paragraph>
253</tablecell>
254</tablerow>
255<tablerow>
256<tablecell>
257<paragraph xml-lang="en-US" id="par_id3154790" role="tablecontent" l10n="U">[:alpha:]</paragraph>
258</tablecell>
259<tablecell>
260<paragraph xml-lang="en-US" id="par_id3147397" role="tablecontent" l10n="CHG">Represents an alphabetic character. Use [:alpha:]+ to find one or more of them.</paragraph>
261</tablecell>
262</tablerow>
263<tablerow>
264<tablecell>
265<paragraph xml-lang="en-US" id="par_id3152885" role="tablecontent" l10n="U">[:digit:]</paragraph>
266</tablecell>
267<tablecell>
268<paragraph xml-lang="en-US" id="par_id3150010" role="tablecontent" l10n="CHG">Represents a decimal digit. Use [:digit:]+ to find one or more of them.</paragraph>
269</tablecell>
270</tablerow>
271<tablerow>
272<tablecell>
273<paragraph xml-lang="en-US" id="par_id3153743" role="tablecontent" l10n="U">[:alnum:]</paragraph>
274</tablecell>
275<tablecell>
276<paragraph xml-lang="en-US" id="par_id3153281" role="tablecontent" l10n="CHG">Represents an alphanumeric character ([:alpha:] and [:digit:]).</paragraph>
277</tablecell>
278</tablerow>
279<tablerow>
280<tablecell>
281<paragraph xml-lang="en-US" id="par_id3153726" role="tablecontent" l10n="U">[:space:]</paragraph>
282</tablecell>
283<tablecell>
284<paragraph xml-lang="en-US" id="par_id3150961" role="tablecontent" l10n="CHG">Represents a whitespace character.</paragraph>
285</tablecell>
286</tablerow>
287<tablerow>
288<tablecell>
289<paragraph xml-lang="en-US" id="par_id3150486" role="tablecontent" l10n="U">[:print:]</paragraph>
290</tablecell>
291<tablecell>
292<paragraph xml-lang="en-US" id="par_id3150872" role="tablecontent" l10n="CHG">Represents a printable character.</paragraph>
293</tablecell>
294</tablerow>
295<tablerow>
296<tablecell>
297<paragraph xml-lang="en-US" id="par_id3155854" role="tablecontent" l10n="U">[:cntrl:]</paragraph>
298</tablecell>
299<tablecell>
300<paragraph xml-lang="en-US" id="par_id3152576" role="tablecontent" l10n="CHG">Represents a nonprinting character.</paragraph>
301</tablecell>
302</tablerow>
303<tablerow>
304<tablecell>
305<paragraph xml-lang="en-US" id="par_id3149958" role="tablecontent" l10n="U">[:lower:]</paragraph>
306</tablecell>
307<tablecell>
308<paragraph xml-lang="en-US" id="par_id3145730" role="tablecontent" l10n="CHG">Represents a lowercase character if <emph>Match case</emph> is selected in <emph>Options</emph>.</paragraph>
309</tablecell>
310</tablerow>
311<tablerow>
312<tablecell>
313<paragraph xml-lang="en-US" id="par_id3148455" role="tablecontent" l10n="U">[:upper:]</paragraph>
314</tablecell>
315<tablecell>
316<paragraph xml-lang="en-US" id="par_id3150092" role="tablecontent" l10n="CHG">Represents an uppercase character if <emph>Match case</emph> is selected in <emph>Options.</emph>
317</paragraph>
318</tablecell>
319</tablerow>
320</table>
321<paragraph xml-lang="en-US" id="hd_id5311441" role="heading" level="2" l10n="NEW">Examples</paragraph>
322<paragraph xml-lang="en-US" id="par_id956834773" role="paragraph" l10n="NEW">e([:digit:])?    -- finds 'e' followed by zero or one digit. Note that currently all named character classes like [:digit:] must be enclosed in parentheses.<comment>issue 64368 and 113035</comment></paragraph>
323<paragraph xml-lang="en-US" id="par_id952368773" role="paragraph" l10n="NEW">^([:digit:])$    -- finds lines or cells with exactly one digit.</paragraph>
324<paragraph xml-lang="en-US" id="par_id9568773" role="paragraph" l10n="NEW">You can combine the search terms to form complex searches.</paragraph>
325<paragraph xml-lang="en-US" id="hd_id71413" role="heading" level="3" l10n="NEW">To find three-digit numbers alone in a paragraph</paragraph>
326<paragraph xml-lang="en-US" id="par_id2924283" role="code" l10n="NEW">^[:digit:]{3}$</paragraph>
327<paragraph xml-lang="en-US" id="par_id5781731" role="paragraph" l10n="NEW">^ means the match has to be at the start of a paragraph,</paragraph>
328<paragraph xml-lang="en-US" id="par_id6942045" role="paragraph" l10n="NEW">[:digit:] matches any decimal digit,</paragraph>
329<paragraph xml-lang="en-US" id="par_id4721823" role="paragraph" l10n="NEW">{3} means there must be exactly 3 copies of "digit",</paragraph>
330<paragraph xml-lang="en-US" id="par_id5806756" role="paragraph" l10n="NEW">$ means the match must end a paragraph.</paragraph>
331<section id="relatedtopics">
332<embed href="text/shared/01/02100000.xhp#02100000"/>
333<switch select="appl">
334<case select="WRITER"><embed href="text/swriter/guide/search_regexp.xhp#search_regexp"/>
335<embed href="text/swriter/guide/finding.xhp#finding"/>
336</case>
337</switch>
338<paragraph xml-lang="en-US" id="par_id1751457" role="paragraph" l10n="NEW"><link href="https://wiki.openoffice.org/wiki/Documentation/How_Tos/Regular_Expressions_in_Writer">Wiki page about regular expressions in Writer</link></paragraph>
339<paragraph xml-lang="en-US" id="par_id5483870" role="paragraph" l10n="NEW"><link href="https://wiki.openoffice.org/wiki/Documentation/How_Tos/Regular_Expressions_in_Calc">Wiki page about regular expressions in Calc</link></paragraph>
340</section>
341</body>
342</helpdocument>
343