blah blah blah is here! blah blah » Close

up0down
link

I am trying to count all of the words in a richtextbox via regex.Matches. Right now I am using "\w+", but that matches words with apostrophe's twice (ex. he's). Is this possible?

last answered 2 years ago

1 answers

up0down
link

\w is equivalent (in English cultures) to [a-zA-Z_0-9] and so doesn't include the apostrophe.
So, if you want to regard the apostrophe as being part of the word you'll need to replace \w with [a-zA-Z_0-9']
You might also want to include the hyphen between the [] as well.

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback