You can use String.replace() with regex like this https://regex101.com/r/X7ioxu/1
var regex = /(\(.+?\))\s?\(/g;
var str1 = "This thing (123, 12) (2005.03 - 2011.12)";
var str1 = "This thing (2005.03 - 2011.12)";
alert(str1.replace(regex,'('));
alert(str2.replace(regex,'('));
More Related Contents:
- Is there a RegExp.escape function in JavaScript?
- How do you use a variable in a regular expression?
- How can I parse a CSV string with JavaScript, which contains comma in data?
- Replace multiple strings with multiple other strings
- How can I extract a number from a string in JavaScript?
- Check whether a string matches a regex in JS
- Split a string by commas but ignore commas within double-quotes using Javascript
- Extract hostname name from string
- Matching a Forward Slash with a regex
- How to find a number in a string using JavaScript?
- How can I concatenate regex literals in JavaScript?
- escaping question mark in regex javascript
- Javascript regex (negative) lookbehind not working in firefox
- JavaScript/regex: Remove text between parentheses
- JavaScript Regex, where to use escape characters?
- javascript regex for password containing at least 8 characters, 1 number, 1 upper and 1 lowercase [duplicate]
- JavaScript Regular Expression Email Validation [duplicate]
- Extract image src from a string
- how to extract floating numbers from strings in javascript
- How to prevent invalid characters from being typed into input fields
- How to convert “camelCase” to “Camel Case”?
- Regex for parsing single key: values out of JSON in Javascript
- What’s the correct regex range for javascript’s regexes to match all the non word characters in any script?
- javascript split string by space, but ignore space in quotes (notice not to split by the colon too)
- Mask US phone number string with JavaScript
- JavaScript remove ZERO WIDTH SPACE (unicode 8203) from string
- What’s different between Python and Javascript regular expressions?
- Extract keyword from Google search in Javascript
- Regex matching emoticons
- Regex: only alphanumeric but not if this is pure numeric