Auto-fix option for double-caps
Auto-fix option for double-caps
Could an option be added to Quick-fix to correct instances of double capitalization, such as this: NEw YOrk.
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Auto-fix option for double-caps
Nisus Writer has such an option (in our QuickFix preferences), but only for text that occurs at the start of a sentence. I can see how this correction might be useful elsewhere. Thanks for the suggestion.
Re: Auto-fix option for double-caps
I would love that option, but also allow it to ignore a whitelist or something. Or at least check if the word is all caps before correcting it.
Re: Auto-fix option for double-caps
Reviving this thread, has there been any progress on this? I have been able to construct RegEx find strings which work… for NWP:
or for other PCRE-using apps
but I can't find a way to replace the second found with its lowercase equivalent. Do any of you coding gurus know the answer, or is it just not possible to do?

Mark
Code: Select all
\<(\p{Upper})(\p{Upper})(\p{Lower}+)
Code: Select all
\b([A-Z])([A-Z])([a-z]+)

Mark
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Auto-fix option for double-caps
Hi Mark! This is definitely possible. You want to use the "Transform" regex features in Nisus Writer with the following replacement expression:
Code: Select all
\1\T{lowercase:\2}\3
I do have one irrelevant improvement for you, if you'll be patient with me

With that in mind you can use regex lookahead and lookbehind features (Nisus Writer calls these FollowedBy and PrecededBy) to avoid replacing the text around the 2nd capital letter. Here's the find pattern that only matches the single capital letter you want to transform:
Code: Select all
(?<=\p{Upper})(\p{Upper})(?=\p{Lower}+)
Code: Select all
\T{lowercase:\1}
Re: Auto-fix option for double-caps
Thanks Martin,
Of course your least-amount-of-text solution works beautifully. I haven't tested your first replace string—I've been busy, particularly having just taken delivery of a M2 Pro Mac Mini, which I've been setting up to replace the iMac—but I'm sure it will work. My task will be to work out how to accomplish them in PCRE RegEx. But that's my problem!

Mark
Of course your least-amount-of-text solution works beautifully. I haven't tested your first replace string—I've been busy, particularly having just taken delivery of a M2 Pro Mac Mini, which I've been setting up to replace the iMac—but I'm sure it will work. My task will be to work out how to accomplish them in PCRE RegEx. But that's my problem!

Mark