Some remarks :
- Your regular expression will work only with IPv4, with the dot-decimal notation (1)
- As Lee Byron pointed out, it will allow IP addresses like 999.999.999.999, which is invalid.
- You should use regular expression litterals, to avoid double-escaping, and this is (I think) simpler to write. Instead of writing this:
var r = new RegExp("my\\.regex", "gi");
This isn't a trivial question so I think it deserves an articulate answer. Few points have been already expressed in other answers but I think listing all of them can help clarity:
1) fast and easy to prototype: makes extremely easy to prototype (almost) any kind of web application in a shorter time when compared with others like for example JAVA and LAM... (more)
This quirk has always felt like a misfeature of the language to me. The only rationale that I can think of is that the array might have elements of mixed types, such as strings and numbers together (or objects or booleans or functions or undefined values, oh my!). In such cases, for better or worse, because JS defines a straightforward way to coerce any v... (more)