18997RE: [Clip] Re: Need help on breaking lines, capitalization
- Mar 9, 2009Thanks, Sheri!
I actually did something similar, but felt it was inelegant so was looking for an improvement. I like some of the things you've
done, which I will implement into mine.
Some comments about assumptions:
1. Not every colon is a suspect - only the ones that follow 'TestString:' need to be changed. That just changes the Find.
2. Not every case has a comma - some have none, some have one, some have more. I used an IfError to process through them.
3. I use [##] elsewhere in my code, so I used \[SC\] as my tag. (Sentence case). I also do \[UC\] for upper case, and delete
those all at the end of that clip section.
I used the toolbar Sentence Case instead of your Insert Text. I will play with that, I really prefer to use Regex rather than the
toolbar. I do this several places elsewhere also, so I'll look to reconstructing those. I'll probably keep what I have for line
breaking but will use your method of Capping.
From: email@example.com [mailto:firstname.lastname@example.org] On Behalf Of Sheri
Sent: Monday, March 09, 2009 6:12 AM
Subject: [Clip] Re: Need help on breaking lines, capitalization
--- In email@example.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
> Hi all,
> I have a coding problem that I can't quite figure out, but I suspect it is easily done.
> In a text document of hundreds to thousands of lines, there are a few that contain strings of text that I want to break out onto
> their own lines, and capitalize the first letter. The line always starts with a recognizable name followed by a colon.
> TestString: sample string 1, sample string 2, sample string 3
> Desired output:
> Sample string 1
> Sample string 2
> Sample string 3
> I appreciate any assistance!
You could do something like this:
^!Find "^\w+: .+,.*" RS
^!Replace "((?<=:)|,) " >> "\r\n#" RAHS
^!Find "^\x23." RS
;end of clip
It assumes the colon is after the first word on a line, and there is at least one comma on that line. Each of the colon and the
comma(s) need to be followed by one space. It breaks all such lines into multiple lines and marks lines that need to be capitalized
with a #. Then it goes through and finds the first two characters on lines that begin with a "#" and inserts over the selection the
uppercase version of the 2nd character in the selection. One command in the clip has the hex value of "#" in it (\x23) because
otherwise NoteTab substitutes the document name for "^#" (caret pound).
[Non-text portions of this message have been removed]
- << Previous post in topic