Reputation: 1675
I need a regex to select a word that each char on that word separated by whitespace. Look at the following string
Mengkapan,Sungai Apit,S I A K,Riau,
I want to select S I A K
. I am stuck, I was trying to use the following regex
\s+\w{1}\s+
but it's not working.
Upvotes: 1
Views: 73
Reputation: 163457
You could match a word boundary \b
, a word character \w
and repeat at least 2 times a space and a word character followed by a word boundary:
\b\w(?: \w){2,}\b
Upvotes: 2
Reputation: 186803
I suggest
\b[A-Za-z](?:\s+[A-Za-z])+\b
pattern, where
\b - word boundary
[A-Za-z] - letter (exactly one)
(?: - one or more groups of
\s+ - white space (at least one)
[A-Za-z] - letter (exactly one)
)+
\b - word boundary
Upvotes: 2