C# Regex: only letters followed by an optional .

Posted by TheDude on Stack Overflow See other posts from Stack Overflow or by TheDude
Published on 2011-01-04T21:41:59Z Indexed on 2011/01/04 21:53 UTC
Read the original article Hit count: 188

Filed under:
|
|

Hello,

I am looking for a way to get words out of a sentence. I am pretty far with the following expression:

\b([a-zA-Z]+?)\b

but there are some occurrences that it counts a word when I want it not to. E.g a word followed by more than one period like "text..". So, in my regex I want to have the period to be at the end of a word zero or one time. Inserting .? did not do the trick, and variations on this have not yielded anything fruitful either.

Hope someone can help!

© Stack Overflow or respective owner

Related posts about c#

Related posts about regex