Regex expression to capture only words without numbers or symbols

Viewed 4136

I need some regex that given the following string:

"test test3 t3st test: word%5 test! testing t[st"

will match only words in a-z chars:

Should match: test testing

Should not match: test3 t3st test: word%5 test! t[st

I have tried ([A-Za-z])\w+ but word%5 should not be a match.

2 Answers

Try this

Pattern tokenPattern = Pattern.compile("[\\p{L}]+");

[\\p{L}]+ this prints group of letters

Related