Hi,

Can you tell me what is the regular expression for a comma-separated list (in this case - IPs) ?
My list looks like this:

192.168.0.1, 10.%.23.100, %.46.%.1

So far I managed to create this:

^[0-9%]{1,3}.[0-9%]{1,3}.[0-9%]{1,3}.[0-9%]{1,3}$

But I don't know how to specify a comma-separated list of the above sequence.

Thanks,
Ender

Maybe I am not understanding what you want to do, but why not split the string on the comma?

if you do this:

var str="123.25.12.135,15.45.85.12,25.85.45.58";


var array = str.split(",");

for(wordIndex in array)
{
     //array[wordIndex] is each individual address
     //run REGEX on each one to determine if it is valid or whatever you are planning

}

Better yet... str.split(/\s*,\s*/) which will get rid of white spaces before and after comma... This would take care of "ab,c, de , g,h,i" as an array with elements ["ab", "c", "de", "g", "h", "i"] instead of ["ab", "c", " de ", " g", "h", i"] as the suggested above post. Though, the above post is going on the right track. :)

PS: This thread is almost a month old already!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.