RE: Search and Replace with a Regular Expression

2006-08-10 Thread Gene Kwiecinski
>>I agree with Chip and have a recommendation. Since you have been >>using Vim, Perl will be much easier to learn. >>When I first began studying programming Perl was over my head and >>seemed very difficult. >I found it incredibly easy to learn Perl. I was faced with a large >data-reformatt

Re: Search and Replace with a Regular Expression

2006-08-04 Thread Matthew Winn
On Fri, 4 Aug 2006 09:07:35 -0400, striker <[EMAIL PROTECTED]> wrote: > I agree with Chip and have a recommendation. Since you have been > using Vim, Perl will be much easier to learn. > A very good beginning book on Perl is located at http:// > learn.perl.org/library/beginning_perl/ . It is

Re: Search and Replace with a Regular Expression

2006-08-04 Thread A.J.Mechelynck
Marv Boyes wrote: Actually, I'm a Linux guy; just trapped behind Windows at work (though VMWare Player and an Ubuntu image get me through). I would have loved to have used Perl, if I had the faintest notion how. When it comes to programming, I never mad it beyond "intermediate" bash scripting, a

Re: Search and Replace with a Regular Expression

2006-08-04 Thread striker
I agree with Chip and have a recommendation. Since you have been using Vim, Perl will be much easier to learn. A very good beginning book on Perl is located at http:// learn.perl.org/library/beginning_perl/ . It is not as thorough as the 'Camel' book, but has a lot of good info. and the pri

Re: Search and Replace with a Regular Expression

2006-08-04 Thread Marv Boyes
Thanks so much to everyone who chimed in on this one. Most of your suggestions produced something useful (and I tried 'em all, even after I had what I needed), and ALL of them are highly educational -- I'll probably study this thread for days. Thanks again, Marv On 8/3/06, Marv Boyes <[EMAIL PRO

Re: Search and Replace with a Regular Expression

2006-08-04 Thread Marv Boyes
Actually, I'm a Linux guy; just trapped behind Windows at work (though VMWare Player and an Ubuntu image get me through). I would have loved to have used Perl, if I had the faintest notion how. When it comes to programming, I never mad it beyond "intermediate" bash scripting, and enough Python to

Re: Search and Replace with a Regular Expression

2006-08-04 Thread Marv Boyes
Chip, your solution worked beautifully. It didn't expand all of the years to four digits, but the new database app will take care of that. I really appreciate the help. Best wishes, Marv On 8/3/06, Charles E Campbell Jr <[EMAIL PROTECTED]> wrote: Marv Boyes wrote: > > For example, let's say I

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Ben K.
For example, let's say I have some dates that look like this: 7-30-05 12-5-2006 10-2-06 What I'd like to end up with is this... 07/30/2005 12/05/2006 10/02/2006 Sorry this is a bit off topic: I just wanted to add that ms excel, or s

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Bill McCarthy
On Thu 3-Aug-06 9:49am -0600, Jürgen Krämer wrote: Very nice explanation! Two minor cosmetic improvements are (1) to use Vim's line continuation to break up that very long line and (2) making the regex "very magic" (your use of comma eliminated 2 escapes, \v eliminates another 13 escapes. So:

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Tim Chase
("0" . submatch(1))[-2:] Hmmm...a nifty new feature in vim7 that is here on my work machine, but unavailable on my hosting service (still running 6.3). Looks like a much-needed pilfering from Python's handy slicing syntax. :) well, then, strpart("0" . submatch(1), strlen(submatch(1))

Re: Search and Replace with a Regular Expression

2006-08-03 Thread A.J.Mechelynck
Tim Chase wrote: right('0'.submatch(1), 2) to zero-pad to 2 places. Alas, the substitute() trick is the easiest way I've found to simulate this. [...] ("0" . submatch(1))[-2:] Hmmm...a nifty new feature in vim7 that is here on my work machine, but unavailable on my hosting service

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Tim Chase
right('0'.submatch(1), 2) to zero-pad to 2 places. Alas, the substitute() trick is the easiest way I've found to simulate this. [...] ("0" . submatch(1))[-2:] Hmmm...a nifty new feature in vim7 that is here on my work machine, but unavailable on my hosting service (still runnin

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Charles E Campbell Jr
martin kraegeloh wrote: part of a good job is to choose the right tool. use perl for this kind of task. use vim to edit the perl script ;-) and search cpan before creating your own solutions! Two problems with this approach: * Perl's regular expressions don't appear to be much more powerfu

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Charles E Campbell Jr
Marv Boyes wrote: For example, let's say I have some dates that look like this: 7-30-05 12-5-2006 10-2-06 What I'd like to end up with is this... 07/30/2005 12/05/2006 10/02/2006 ...without, of course, having to re-type every single one

Re: Search and Replace with a Regular Expression

2006-08-03 Thread A.J.Mechelynck
Tim Chase wrote: [...] I broke it out into multiple lines to hopefully make more sense of it. The first two substitute() lines add a zero on the left of whatever they found, and then take whatever the rightmost two characters of the result are...effectively padding them with zeros on the left

Re: Search and Replace with a Regular Expression

2006-08-03 Thread martin kraegeloh
part of a good job is to choose the right tool. use perl for this kind of task. use vim to edit the perl script ;-) and search cpan before creating your own solutions! /martin begin:vcard fn:Martin Kraegeloh n:Kraegeloh;Martin adr:;;Am Alten Pfarrhof 24;Oberbergkirchen;;84564;Germany email;int

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Jürgen Krämer
Hi, Tim Chase wrote: >>> zeros on the left if needed. Ideally, Vim would provide a >>> right() function where you could just do something like >>> >>> right('0'.submatch(1), 2) >>> >>> to zero-pad to 2 places. Alas, the substitute() trick is the >>> easiest way I've found to simulate this

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Tim Chase
zeros on the left if needed. Ideally, Vim would provide a right() function where you could just do something like right('0'.submatch(1), 2) to zero-pad to 2 places. Alas, the substitute() trick is the easiest way I've found to simulate this. repeat('0', 2 - strlen(submatch(1))) .

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Jürgen Krämer
Hi, Tim Chase wrote: > [...] > > I broke it out into multiple lines to hopefully make more sense > of it. The first two substitute() lines add a zero on the left > of whatever they found, and then take whatever the rightmost two > characters of the result are...effectively padding them with

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Tim Chase
I can't seem ot get the hang of it for this particular job. Well, even as a regexp wonk, it's a bit of a daunting task you have before you. :) Most of the problem is with dates, in that I have a mishmash of formats. Since you don't mention any other problematic sections, I guess I'll focu

Re: Search and Replace with a Regular Expression

2006-08-03 Thread Jürgen Krämer
Hi, Marv Boyes wrote: > Hello, all. I've been tasked with migrating a large MS Works > "database" into the 21st century. The thing's original setup didn't > enforce any sort of standardization in data entry, so there are nearly > as many different formats and styles in the data as there have been

Search and Replace with a Regular Expression

2006-08-03 Thread Marv Boyes
Hello, all. I've been tasked with migrating a large MS Works "database" into the 21st century. The thing's original setup didn't enforce any sort of standardization in data entry, so there are nearly as many different formats and styles in the data as there have been people entering it. My best be