Am 1. Apr. 2019, 18:01 +0200 schrieb Lee Hinde <leehi...@gmail.com>:
> I have a CSV file where the 2nd column contains names that are being provided 
> all caps. I'd like to title case that column.
>
> First column is a number, always, so:
>
> 123,HUMAN RESOURCES,....
> 124,PUBLICATIONS,....
>
> I'd like to convert that to:
>
> 123,Human Resources,....
> 124,Publications,....
>
> Is that doable with RegEx?  A quick google didn't provide anything I 
> understood. (low bar)
The problem with this example data is, that you have a variable number of words 
that need to be „case-transformed“.  Regular expressions are a bit of a head 
scratcher when it comes to variable occurrences of targets. If you wanted to 
„sentence-case“ that column it would be rather easy:
search:
^(.+?),(.)(.+?),
replace:
\1,\u\2\L\3,
Check BBEdit Help > Grep > Writing Replacement Patterns for the \u\U\l\L\E 
specifiers.

But that would give you "123,Human resources,….“ instead of "123,Human 
Resources,….“ You could add more search-replace operations searching for a 
space and a lowercase character but that is kind of unsatisfying.
As „title case“ is not a grep option (at least not to my knowledge) you have 
two options: a) getting ambitious and thinking about scripting solution or b) 
walk down the pragmatic way. That would be:

1. Open the file in a spreadsheet app
2. Copy the second column to BBEdit
3. Text > Change Case > Title Case
4. Paste it back into the spreadsheet

Also: the younger incarnations of BBEdit give you some support for working with 
columns. With the cursor in (any) column 2 of your text: Edit > Columns > New 
Document with Columns. As above: change the case and copy the text back using a 
vertical insertion selection and Columns > Rearrange

Roland

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <https://www.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+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to