Hi Peter,

Well the problem is that I need to also move the ":" to the front of the
bracketed expression, although I like the simplicity of your statement. I
cannot replace all of the "[" with ":[" because I am actually just using a
small example from a large file, and there are many more "[" that are
unaffected.

Rebecca

On Mon, Aug 15, 2011 at 6:40 PM, Peter Langfelder <
peter.langfelder@gmail.com> wrote:

> On Mon, Aug 15, 2011 at 10:34 AM, Rebecca Gray <atlasrrg@gmail.com> wrote:
> > Hello all,
> >
> > I have what I think is a simple question but I've been unable to solve
> it. I
> > have the following string:
> >
> > A[&states=1]:[&rate=2]425, B[&states=3]:[&rate=5]500
> >
> > I would like to combine the two expressions in the [], so that only one
> set
> > of [] is present after each letter, so that I have the following string:
> >
> > A:[&states=1,&rate=2]425, B:[&states=3,&rate=5]500
> >
> > I tried this:
> >
> >> Y <- gsub("\\[&states=.\\]:\\[&",":\\[&states=.,", X)
> >
> > which almost works, except that it replaces the numbers associated with
> > "states" with the period - not retaining the original value as I thought
> the
> > wildcard character would.
>
> How about a simpler solution:
>
> x = "A[&states=1]:[&rate=2]425, B[&states=3]:[&rate=5]500"
>
> gsub("]:[", ", ", x, fixed = TRUE)
>
> i.e., simply replace ]:[ by ,
>
> will that work?
>
> Peter
>

	[[alternative HTML version deleted]]

