Regular Expressions and OpenOffice

From MKRD.info Wiki
Revision as of 19:13, 27 June 2011 by Mkrdwiki (talk | contribs) (Created page with "Linux is extraordinary powerful with its processing commands like grep. However, OpenOffice Search and Replace has some of that power, one that few people are aware of. A few e...")

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)

Linux is extraordinary powerful with its processing commands like grep. However, OpenOffice Search and Replace has some of that power, one that few people are aware of.


A few examples with using OpenOffice to process data:


Find line containing string

.*SearchTerm.*$


Replace by placing find result on a new line

\r&\r


Find several characters within a range of allowed character values

[A-Za-z0-9.-]*


Find an e-mail address

[A-Za-z0-9.-]+@[A-Za-z0-9.-]+ (note -- I do not claim this to be the perfect filter for finding emails)


Sort list of lines

That option is now available in Writer, but I used to have to use Calc (spreadsheet) for that.


Remove duplicates from list of lines

I usually do something like this by copy-pasting into Calc (the spreadsheet Open Office equivalent), highlighting that whole column, going Data>Filter>Standard filter. Under "Value" choose -not empty-. Click "More Options". Select "No Duplicates", then click OK. Paste the resulting list back into the Writer file.