View difference between Paste ID: TP6iVpMK and nEDBc4Ey
SHOW: | | - or go back to the newest paste.
1
	var str = "127.0.0.1";
2-
	var matches = str.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
2+
	var matches = str.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
3
	if (matches.length > 0) {
4
		var a = parseInt(matches[1]);
5
		var b = parseInt(matches[2]);
6
		var c = parseInt(matches[3]);
7
		var d = parseInt(matches[4]);
8
		if (a >= 1 && a <= 255 &&
9
			b >= 0 && b <= 255 &&
10
			c >= 0 && c <= 255 &&
11
			d >= 0 && d <= 255) {
12
			alert('IP');
13
		}
14
	}