Regex to match words and those with an apostrophe

Posted by Beau Martínez on Stack Overflow See other posts from Stack Overflow or by Beau Martínez
Published on 2010-04-08T00:53:45Z Indexed on 2010/04/08 1:13 UTC
Read the original article Hit count: 464

Filed under:
|

I'm looking for a regex to only match words, possibly including numbers, and possibly with an apostrophe at the beginning, middle, or end; and ignore everything else.

So these would be matched verbatim:

  • 'bout
  • it's
  • persons'

But these would be ignored:

  • '
  • ''

However, for words like 'open', open should be matched.

© Stack Overflow or respective owner

Related posts about python-3.x

Related posts about regex