Using replace
(.)\1+
demo
var str="AABAAABBC"
var res = str.replace(/(.)\1+/g, (match, p1) => match.length + p1)
console.log(res)
More Related Contents:
- What’s the prettiest way to compare one value against multiple values? [duplicate]
- Why does string to number comparison work in Javascript
- javascript is creating date wrong month
- change values in array when doing foreach
- How to execute a function when page has fully loaded?
- Convert special characters to HTML in JavaScript
- detect ipad/iphone webview via javascript
- Get page generated with Javascript in Python
- Refresh a page using JavaScript or HTML [duplicate]
- How to convert uint8 Array to base64 Encoded String?
- Can I pass parameters in computed properties in Vue.Js
- Adding additional data to select options using jQuery
- How can I get the index of an array in a Meteor template each loop?
- Calculating Jday(Julian Day) in javascript
- D3 force layout – linking nodes by name instead of index
- What is an “internal slot” of an object in JavaScript?
- localStorage access from local file
- How to parse JSON string in Typescript
- Calling webpage JavaScript methods from browser extension
- jQuery() not finding elements in jQuery.parseHTML() result
- How can I disable all typescript type checking?
- node.js /socket.io/socket.io.js not found
- Maximum item size in IndexedDB
- Responding to the onmousemove event outside of the browser window in IE
- React hook useEffect runs continuously forever/infinite loop
- MissingSchemaError: Schema hasn’t been registered for model “User”
- jQuery addClass onClick
- Could a website force the browser to go into fullscreen mode?
- Retrieving which tabs are open in Chrome?
- How do you round to one decimal place in JavaScript?