You can use regex with positive look ahead,
"1.2.3.4".replace(/[.](?=.*[.])/g, "");
More Related Contents:
- jQuery selector regular expressions
- How to capture an arbitrary number of groups in JavaScript Regexp?
- Regex pattern to match at least 1 number and 1 character in a string
- Alternation operator inside square brackets does not work
- Regex using javascript to return just numbers
- regex.test V.S. string.match to know if a string matches a regular expression
- Convert camelCaseText to Title Case Text
- Regular expression not working for at least one European character
- Regular expression to match A, AB, ABC, but not AC. (“starts with”)
- How to parse a URL?
- List of all characters that should be escaped before put in to RegEx?
- Match any non-word character (excluding diacritics)
- How can I select an element by ID with jQuery using regex?
- Why does String.match( / \d*/ ) return an empty string?
- Regex to replace everything except numbers and a decimal point
- RegEx: How can I match all numbers greater than 49?
- How do I split a string by whitespace and ignoring leading and trailing whitespace into an array of words using a regular expression?
- In a regular expression, match one thing or another, or both
- (*SKIP)(*FAIL) workaround in JavaScript RegExp
- What are non-word boundary in regex (\B), compared to word-boundary?
- What is the need for caret (^) and dollar symbol ($) in regular expression?
- Replacing accented characters with plain ascii ones [duplicate]
- Javascript RegExp for splitting text into sentences and keeping the delimiter
- How to insert space every 4 characters for IBAN registering?
- Regular Expression Pattern With A Variable
- How can I use regex to get all the characters after a specific character, e.g. comma (“,”)
- Regex to grab strings between square brackets
- parsings strings: extracting words and phrases [JavaScript]
- What’s different between Python and Javascript regular expressions?
- Regex: only alphanumeric but not if this is pure numeric