1

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
  • 111
  • 2
  • 12

2 Answers2

4

This should match a single letter between word boundaries

/\b(\w)\b/
fallenland
  • 525
  • 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 – OtherDevOpsGene 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
  • 19,729
  • 13
  • 73
  • 118