Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Removing all but the first letter of every word using regex in LibreOffice Writer

I have found a couple posts around the internet and on here on how to remove all but the first letter of every word in a paragraph (or the whole text) using regex and Microsoft Word, but nothing has seemed to work in LibreOffice Writer.

I have been trying to use the Find and Replace dialog and have regular expressions checked in the options.

As an example:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Would become:

L i d s a, c a e, s d e t i u l e d m a.

Keeping punctuation and case sensitivity would be great. I also am not opposed to using a different method/program for this.

>Solution :

Assuming LibreOffice’s regex support fixed width lookbehinds, you could match on the following pattern:

(?<=\w)\w

and then replace with empty string. This pattern will match any word character except those not preceded by word characters (e.g. at the start of a word).

Here is a running demo.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading