Reputation: 77
I need regular expression which would match a sentence in a text file. By sentence I mean a string which starts with capital letter and ends with a period. So far I've came up with this:
[A-Z]+[A-Za-z0-9_,"#;.() \t]+[.]$
It's kind of working, but there's a little problem. When there are few sentences in one line, it sums them up and count as one. Any tips how to fix it?
Upvotes: 0
Views: 97
Reputation: 3446
I would extend this to [A-Z][\s\S]+?[.?!]+
. "LOOK OUT!!" is a sentence in my book. Also allows for sentences with whitespace between them.
Upvotes: 0