javascript - Regex not working properly with info from API -
i'm having weird problem. i'm running script in adobe's extendscript toolkit (to use photoshop) info api, , regex extract 6 digit number part of it, part being:
'save 585190 j.crew ou + 591580 polo ralph lauren ou'
the api working fine, , script (i've replaced website hidden protect identity):
currentpid = activedocument.name.substring(0,6) reply = ""; conn = new socket(); conn.open ("hidden.com:80", "binary") conn.write ("get http://hidden.com/api/products/" + currentpid + "/for-studio?content-type=application/json http/1.0\r\nhost:website.com\r\nconnection: close\r\n\r\n"); reply = conn.read(999999); var result = reply.substr(reply.indexof("\r\n\r\n")+4); var showme = json.parse(result) conn.close(); mycomments = showme.comments myregex = new regexp("(?!" + currentpid + ")\\d{6}"); var posspid = (mycomments.match(myregex));
however, when run this, points last line , gives me error:
'mycomments.match not function'
and yet, when modify , run this:
currentpid = 591580 mycomments = 'save 585190 j.crew ou + 591580 polo ralph lauren ou' myregex = new regexp("(?!" + currentpid + ")\\d{6}"); var posspid = (mycomments.match(myregex));
..it runs fine.
what doing wrong here?
Comments
Post a Comment