Re: [SLUG] text processing

From: Paul M Foster (paulf@quillandmouse.com)
Date: Wed Sep 17 2008 - 22:03:31 EDT


On Wed, Sep 17, 2008 at 08:52:20PM -0400, Eben King wrote:

> On Wed, 17 Sep 2008, Paul M Foster wrote:
>
>> On Wed, Sep 17, 2008 at 01:20:48PM -0400, Eben King wrote:
>>
>>> Adding a _capital_ subdirectory is easy enough:
>>>
>>> :^\/s@/mp3/\(.\)@/mp3/\1/\1
>>>
>>> (assuming that doesn't do something disallowed in vim)
>>>
>>> But how do I make the subdirectory lower-case? Or is it easier to make a
>>> capital soft link to each subdirectory, do that, then delete the link?
>>
>> I'm inclined to think you'd have to one of these for each letter of the
>> alphabet.
>
> Yes, that's correct. Big sites do it with home directories.
>
>> Like:
>>
>> :%s/home\/mp3\/A/home\/mp3\/a\/A/g
>>
>> (Excuse me, as I'm not a whiz at Vim regexps). What you're doing is
>> substituting
>>
>> home/mp3/A
>>
>> with
>>
>> home/mp3/a/A
>
> Yes, in the case of Aphex_Twin and Abbot_+_Costello and all those "A"
> groups. But for the rest, would I have to do something similar 26 times?
> Or is there a regexp form that means "insert lowercase(#1) at #2"?
>
> /home/eben/mp3/_/_...
> 2 1
>

I'm not aware of any regexp idiom for lowercasing something. That's why
I say that you'd probably have to do this same thing for B/b, C/c, etc.

Of course, you could probably attack this with Perl, Python or Awk, and
there are built-in functions for lowercasing things. But that's a more
complex procedure. It *might* save you time, depending on how long it
took you to code it.

Paul

-- 
Paul M. Foster
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:58:05 EDT