[R] find and replace string

christiaan pauw cjpauw at gmail.com
Fri Dec 2 13:52:36 CET 2011


If the length of the fists part is constant (the "sta_+1+" part) the
you can use substr()




On 2 December 2011 13:30, Alaios <alaios at yahoo.com> wrote:
>
 Dear all,
> I would like to search in a string for the second occurrence of a symbol and replace the symbol after it
>
> For example my strings look like
>
> sta_+1+0_field2ndtry_0000$01.cfg
>
> I want to find the digit that comes after the second +, in that case is zero
> and then over a loop create the strings below
>
> sta_+1+0_field2ndtry_0000$01.cfg
>
> sta_+1+1_field2ndtry_0000$01.cfg
>
> sta_+1+2_field2ndtry_0000$01.cfg
>
> sta_+1+3_field2ndtry_0000$01.cfg
>
> and so on..
> I have already tried strsplit but this will make things more complex...
>
> Could you please help me with that?
>
> B.R
> Alex
>



--
Christiaan Pauw
Nova Institute
www.nova.org.za



More information about the R-help mailing list