Difference between revisions of "Documentation/How Tos/Regular Expressions in Calc"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Initial content added)
 
m (added more content)
Line 20: Line 20:
  
 
In Calc, regular expressions are applied separately to each cell. (You'll see that regular expressions are applied separately to each paragraph in Writer.) So a search for ''''r.d'''' will match red in cell A1 but will not match ''''r'''' in cell A2 with ''''d'''' (or ''''ed'''') in cell A3. (The regular expression ''''r.d'''' means 'try to match ''''r'''' followed by another character followed by ''''d'''' ').
 
In Calc, regular expressions are applied separately to each cell. (You'll see that regular expressions are applied separately to each paragraph in Writer.) So a search for ''''r.d'''' will match red in cell A1 but will not match ''''r'''' in cell A2 with ''''d'''' (or ''''ed'''') in cell A3. (The regular expression ''''r.d'''' means 'try to match ''''r'''' followed by another character followed by ''''d'''' ').
 +
 +
 +
== Regular expressions in Calc functions ==
 +
 +
There are a number of functions in Calc which allow the use of regular expressions - for example: ''''SUMIF'''', ''''COUNTIF'''', ''''MATCH'''', ''''LOOKUP'''', ''''HLOOKUP'''', ''''VLOOKUP'''', and the 'database' functions ''''DCOUNT'''', ''''DSUM'''' etc.
 +
 +
 +
Whether or not regular expressions are used is selected on the Tools - Options - OpenOffice.org Calc - Calculate dialog:
 +
 +
 +
[[Image:Regex_howto_2.png|choosing to use regular expressions in Calc functions]]

Revision as of 04:46, 25 October 2007

Introduction:

In simple terms regular expressions are a clever way to find text.


A typical use for regular expressions is in finding text; for instance to locate all cells containing man or woman in your spreadsheet, you could search using a single regular expression.


Regular expressions in Calc and Writer

Regular expressions are available in Calc as follows:

  • Edit - Find & Replace dialog
  • Data - Filter - Standard filter
  • Functions, such as SUMIF, LOOKUP

The best way to learn about regular expressions in Calc is to start by understanding how to use Find & Replace. This is covered by the 'HowTo for Regular Expressions in Writer', which you should read.


In Calc, regular expressions are applied separately to each cell. (You'll see that regular expressions are applied separately to each paragraph in Writer.) So a search for 'r.d' will match red in cell A1 but will not match 'r' in cell A2 with 'd' (or 'ed') in cell A3. (The regular expression 'r.d' means 'try to match 'r' followed by another character followed by 'd' ').


Regular expressions in Calc functions

There are a number of functions in Calc which allow the use of regular expressions - for example: 'SUMIF', 'COUNTIF', 'MATCH', 'LOOKUP', 'HLOOKUP', 'VLOOKUP', and the 'database' functions 'DCOUNT', 'DSUM' etc.


Whether or not regular expressions are used is selected on the Tools - Options - OpenOffice.org Calc - Calculate dialog:


choosing to use regular expressions in Calc functions

Personal tools