Documentation/How Tos/Using Regular Expressions in the Calc Standard Filter
From Apache OpenOffice Wiki
< Documentation | How Tos
Life just is not cut and dried. Sometimes when you are filtering you do not want to just say "give me all the people whose last name is Hanson." You want Hanson, Hansen, and Hansengaaardennn.
You would like to filter out everyone except those whose names contain "Hans".
Here is how to do that.
- Select Data > Filter > Standard Filter from the menu.
- Select the item in the Comparison Field from the dropdown list in the standard filter, then type what you want in the other field.
- Click More Options, and select Regular Expression, then click OK.
Example of what you want |
What to enter in the Condition field |
Syntax for what to enter in the Value field |
Example of what to enter in the Value field |
---|---|---|---|
Begins with Hans |
= |
^x.* |
^Hans.* |
Does not begin with Hans |
<> |
^x.* |
^Hans.* |
Ends with Hans |
= |
.*x$ |
.*Hans$ |
Contains Hans |
= |
.*x.* |
.*Hans.* |
Does not contain Hans |
<> |
.*x.* |
.*Hans.* |
Here are some examples. Let's say you want all names that start with Hans, but not all names that simply contain Hans.
Here is the data.
- Select all the data, or just click in the headings, and choose Data > Filter > Standard Filter.
- Select "Name" under Field name, "=" under Condition and enter "Hans.*" under Value.
- Click OK and you get this; Bob Montrahans is not included. (It is not because of the case.)
Here is a different example. I want names that DO NOT CONTAIN the series of letters Hans.
- Select all the data, or just click in the headings, and choose Data > Filter > Standard Filter.
- Select "Name" under Field name, "<>" under Condition and enter ".*Hans.*" under Value.
- Click OK and you get this.
Template:Documentation/SeeAlso
This How To comes from Solveig Haugland's Blog
Content on this page is licensed under the Public Documentation License (PDL). |