1 Reply Latest reply: Jul 17, 2008 5:53 AM by Newsgroup_User RSS

    help in RegExp

    AScracker Community Member
      hi
      i need to convert the code (0,0,2,84,69,93,76,49) as 0,0,2,84,69,93,76,49.
      How can use the regular exp for this code
      ~~
      SK
        • 1. Re: help in RegExp
          Newsgroup_User Community Member
          AScracker,

          > hi

          Hi!

          > i need to convert the code (0,0,2,84,69,93,76,49) as
          > 0,0,2,84,69,93,76,49.

          Okay.

          > How can use the regular exp for this code

          There are a couple ways it can be done, but in this case I would
          probably use the
          String.replace() method. It could work like this:


          var str:String = "(0,0,2,84,69,93,76,49)";

          var pattern:RegExp = /\(([^)]+)\)/;
          str = str.replace(pattern, "$1");

          trace(str);


          You can see the str variable as your original string. The pattern
          variable is a RegExp instance, set to this pattern: \(([^)]+)\) That looks
          for a left parenthesis followed by any character that isn't a right
          parenthesis (at least once) followed by a right parenthesis. The
          between-the-parentheses match is stored in one of the RegExp's "memory
          slots," like a calculator's M button. The first slot is $1, which is what
          the replace() method uses to replace the match.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."