Monday, July 4, 2011

Regular Expressions on OOo Calc


  • Most characters match themselves. There are exceptions - see below.
    COUNTIF(A1:A100; "foo") will return all the instances of the string "foo" in the specified range.
  • "." matches any single character.
    COUNTIF(B2:B18; "..") counts all cells with exactly two characters.
  • "*" is a special character that matches zero or more occurences of the previous expression.
    COUNTIF(B2:B18; ".*e") counts all cells that end in "e".
  • "+" is a special character that matches one or more occurences of the previous single character.
    COUNTIF(B2:B18; ".+m.+") includes "Tmmy" and "name", but not "my".
  • A string of characters enclosed in square brackets ([]) matches any one character in that string.
    COUNTIF(B2:B18; "[efg].*")
    counts all cells starting with e, f, or g.

No comments:

Post a Comment