[Techtalk] RegEx problem in vim

Gebhard Dettmar gebhard.dettmar at student.hu-berlin.de
Tue Jul 27 13:09:41 EST 2004


techtalk-bounces at linuxchix.org scribbled on Monday, July 26, 2004
10:35 PM

> On Mon, Jul 26, 2004 at 03:06:50PM -0400, Tricia Bowen wrote:
>> You might want to try this pattern to replace the space or newline
>> at the same time: 
>> 
>> :%s/\([A-Z]\)\([ \n]\)/\1.\2/g
> 
> 
> I'd suggest to use the word boundary markers \< \>
> 
> :%s/\<\([A-Z]\)\>/\1./g
> 
> This nicely solves a couple of issues in one go.
> 
> (Hint: assume you had a title like "... in the US and ...".
> Not using boundary markers would turn US into "US.", probably not
> what you want... 
Indeed, e.g. MIT Press in my case. And to make things worse:
Northern Sotho historical dramas: A historical-biographical analysis.
Or
---snip---
Das Neves, D F
	1879	A hunting trip to the Transvaal. London: George Bell.
---snap---
> Even if not strictly required for some given
> input, it's generally a good idea to craft regexes as robust as
> possible against unexpected input.) 
So my exceptions are: number + space and .|: + space. With
\([^: A-Z][A-Z]\) I found seven instances, that mustn't be matched but
I'm too amateurish to write a suitable RegEx ;-(
> Cheers,
> Almut
Regards gebhard
> _______________________________________________
> Techtalk mailing list
> Techtalk at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/techtalk




More information about the Techtalk mailing list