Answered
Regular Expression
How do I write a regular expression to replace everything after the 2nd occurrence of a period?
How do I write a regular expression to replace everything after the 2nd occurrence of a period?
Ah OK. I think a Regular Expression is a bit of an overkill for that.
You can do it using this code:
var s = "123.456.78910.1234";
var parts = s.split(".");
var newS = (parts.length<2) ? parts[0] : parts[0]+"."+parts[1];
console.println(newS);Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.