You should run the re.exec multiple times, like below:

var s = "PROXY mozilla.netscape.com:8081; SOCKS w3proxy.netscape.com:444;DIRECT"
var re = /\s*(\S+)\s+(\S+):(\d*)\s*[;]?\s*/g;

var a;
while (a = re.exec(s))
  alert(a.toSource());

Pls also notice the "g" modifier is a MUST. Otherwise the script will hang.

WC Leung


Eric H. Jung wrote:
Hi,

I'm trying to write a regex which parses 3 pieces of data multiple times. For 
example:

PROXY w3proxy.netscape.com:8080
or
PROXY mozilla.netscape.com:8081;PROXY w3proxy.netscape.com:8080
or
 PROXY   mozilla.netscape.com:8081; SOCKS w3proxy.netscape.com:444;DIRECT

The following works but only keeps the last match set:

  var re = /\s*(\S+)\s+(\S+):(\d*)\s*[;]?\s*/g;

In other words:

  var a = re.exec("PROXY w3proxy.netscape.com:8080; SOCKS moofarm.com:1234");
  a[1] = "SOCKS";
  a[2] = "moofarm.com";
  a[3] = "1234";

but I also want:

  a[x] = "PROXY ";
  a[y] = "w3proxy.netscape.com";
  a[z] = "8080";


Any advice is greatly appreciated.

Thank you,
Eric Jung

Use Your PC To Find a Cure for 
Cancerhttp://members.ud.com/services/teams/team.htm?id=68C9E079-8285-495F-8598-D73352CC7075And
 Join Team Lulu
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

Reply via email to