2

I'm looking for a script that would check the beginning of a paragraph and first character after sentence's terminal (.,?,!), and then it would capitalize required letters.

Thank you for help.

1
  • I'd suggest you additionally require a space after the terminal (hxxp://www.Google.Com). Still not perfect (Yahoo! employees), but fewer false positives.
    – Daniel Beck
    Jan 15, 2011 at 12:50

1 Answer 1

2

Give this a try:

%s/\(^\|[.?!] \+\)./\U&/g

Explanation:

`%` - for every line in the file
`s/` - substitute
`\( \| \)` - a group of alternatives
`^` - after a newline (beginning of paragraph)
`[.?!] \+` - after a terminal punctuation mark and one or more required spaces
`.` - any character (it's not necessary, but you could use `[[:alpha:]]` instead)
`/` - replacement
`\U` - uppercase the following string (it will only affect the `[[:alpha:]]` character
`/g` - end of command and make it apply to every match on a line

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .