#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2009
    Posts
    1
    Rep Power
    0

    Help with creating a regex


    hi all, I am in need of a regex to parse a few strings for a script i'm writing in PHP.

    My data looks like this (it will be in a string)
    Code:
    	var talentsTreeArray=new Array;
    	talentsTreeArray[0]=[1, 50, "example1"];
    	talentsTreeArray[1]=[2, 19, "example2"];
    	talentsTreeArray[2]=[3, 0, "example3"];
    I need to extract the 2nd number (50,19, and 0) and the string in the quotes.

    thanks in advance!
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,993
    Rep Power
    9397
    So use
    Code:
    "talentsTreeArray[" + digits + "]=[" + digits + ", " + digits
    Capture the last bunch of digits.

    Remember to escape the []s, \d represents digits, and that you surround stuff you want with parentheses.

IMN logo majestic logo threadwatch logo seochat tools logo