Changing a lower case letter of the first word to uppercase letter of the first word in a sentence

302 views
Skip to first unread message

Linton Hutchinson

unread,
Mar 5, 2020, 8:42:16 PM3/5/20
to BBEdit Talk
How do I 
Changing a lower case letter of the first word in a sentence to uppercase letter of the first word in the sentence for all entries in a txt file

using GREP?

Fletcher Sandbeck

unread,
Mar 5, 2020, 9:11:04 PM3/5/20
to bbe...@googlegroups.com
This seems to work. It's a little tricky to be sure you're at the start of a sentence so I'd advice cycling through the matches rather than doing a global replace.

Search pattern: (?:^|\. +)[a-z]

Replace pattern: \L\0

Use with grep and case sensitive turned on. The search pattern finds either the start of a line ^ or an escaped period followed by one or more spaces, wrapped in (?: ) so they don't define a sub-pattern. Followed by the lowercase character. The replacement uses \U to make the replacement uppercase. And we replace the whole pattern so we don't lose the period.

Hope this helps,

[fletcher]
> --
> This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
> ---
> You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/125e2ff6-7324-4778-9db9-ed75f11f36df%40googlegroups.com.

Fletcher Sandbeck

unread,
Mar 5, 2020, 9:12:48 PM3/5/20
to bbe...@googlegroups.com
Replace should be \U\0 of course. \L makes it lowercase. \U makes it uppercase.

[fletcher]
> To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/440509A6-AAC4-4F56-B99D-93829D521685%40cumuli.com.

Dr. Linton Hutchinson

unread,
Mar 5, 2020, 11:10:08 PM3/5/20
to bbe...@googlegroups.com

This seems to work Thanks Fletcher

Reply all
Reply to author
Forward
0 new messages