Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regular expression that extracts words from a string

I want to extract all words from a java String.

word can be written in any european language, and does not contain spaces, only alpha symbols.

it can contain hyphens though.

like image 630
EugeneP Avatar asked Sep 29 '26 09:09

EugeneP


1 Answers

If you aren't tied to regular expressions, also have a look at BreakIterator, in particular the getWordInstance() method:

Word boundary analysis is used by search and replace functions, as well as within text editing applications that allow the user to select words with a double click. Word selection provides correct interpretation of punctuation marks within and following words. Characters that are not part of a word, such as symbols or punctuation marks, have word-breaks on both sides.

like image 80
McDowell Avatar answered Oct 01 '26 22:10

McDowell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!