0

I have more words -like apple, orange, banana, a , b , c. i want to select a word with single character only using regex? what to do?

i mean only a, b, c.(answer)

Could anyone help me?

Anitha
  • 91
  • 2
  • 11

2 Answers2

4

This should match a single letter between word boundaries

/\b(\w)\b/
fallenland
  • 505
  • 2
  • 6
  • With the caveat that it won't work on non-ASCII characters: http://stackoverflow.com/questions/10590098/javascript-regexp-word-boundaries-unicode-characters – Gene Gotimer Oct 14 '14 at 12:22
1

The following matches single-character words. \b matches a word boundary, and \w a word character.

\b\w\b
simonzack
  • 17,855
  • 12
  • 65
  • 107