Skip to content
Back to formatted view

Raw Message

Message-ID: <20210209152912.24f4d0c5@rolf-Latitude-E7470>
Date: 2021-02-09T02:29:12Z
From: Rolf Turner
Subject: Help with regular expressions.

I want to deal with strings of the form "a.b.c" and to change (using
sub() or whatever is appropriate) the second "." to a "-", i.e. to
change "a.b.c" to "a.b-c".  I want to leave the first "." as-is.

I guess I could do a gsub(), changing all "."s to "-"s, and then do
a sub() changing the first "-" back to a ".".  But this seems very
kludgy.  There must be a sexier way.  Mustn't there?  Is there regular
expression syntax for picking out the second occurence of a particular
string?

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276