4 Replies Latest reply: Feb 21, 2013 5:25 AM by Image+Type RSS

    Need a Grep Expression for changing a space between braces.

    Image+Type

      Hey All --

       

      I know this has got to be ridiculously simple for anyone that knows Grep.

       

      I have a string of text in braces like this:

      {namevalue="Firstname Lastname”}

       

      And I would like to add any special character or word between the first and last names so I can make some additional changes to the structure via find/replace.

      So I would like to change it to this for example:

      {namevalue="Firstname$$$Lastname”}   or this: {namevalue="FirstnameKAPOWLastname”} or this: {namevalue="Firstname12434Lastname”}

       

      You get the picture. Any assistance will be greatly appreciated.

       

       

       

       


        • 1. Re: Need a Grep Expression for changing a space between braces.
          pkahrel MVP

          Like this:

           

          Find what: (\{namevalue=".+?)\s(?=.+?"\})

          Replace with: $1@@@

           

          (                           // start capture

          \{namevalue="    // literal {namevalue="

          .+?                       // followed by one or more of any character . . .

          )                           // end capture

          \s                         // . . . up to the first space . . .

          (?=.+?"\})             // . . . but only if followed by some characters ending in }

           

          It could be simpler --

           

          Find what: (\{namevalue=".+?)\s

          Replace with: $1@@@

           

          Need coffee.

           

          Peter

          • 2. Re: Need a Grep Expression for changing a space between braces.
            Peter Spier ACP/MVPs

            Just to clarify, is {namevalue="Firstname Lastname”} what actually appears in your text, or is that a generic example and the actual text contains actual names?

             

            What the other Peter first posted is fine if the string is actual, but not for real names. The good news is he edited his post (which you wouldn't know unless you come back to the web page) and his second version should work in either case.

             

            Note to Peter: there's no email update when a post is edited so it's probably better to add a correction post instead. Are we even for the day?

            • 3. Re: Need a Grep Expression for changing a space between braces.
              pkahrel MVP

              > there's no email update when a post is edited so it's probably better to add a correction post instead.

               

              Ah, thanks, I didn't know that.

               

              > Are we even for the day?

               

              Yep. But it's still early. . .

              • 4. Re: Need a Grep Expression for changing a space between braces.
                Image+Type

                Thanks so much Peter(s) -- that is spot-on.

                There are over 600 records like that -- all of them with unique vaues-- so this was a huge help.

                Very much appreciated.