Regular Expressions and OpenOffice

From Wiki
Jump to: navigation, search

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


Replace by placing find result on a new line


Find several characters within a range of allowed character values


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.