Reputation: 131
Background: the init string is always different (but it contains aa== at the beginning and ==b at the end)
example:
var string = 'aa==1234^&==b'
var string = 'aa==hello==b'
var string = 'aa==world!==b'
How to replace the string in the middle part? ? ?
string.replace(????, 'TestOK')
result:
var string = 'aa==TestOK==b'
var string = 'aa==TestOK==b'
var string = 'aa==TestOK==b'
Upvotes: 0
Views: 49
Reputation: 370689
Replacing everything between the ==
s should do it:
const transform = str => str.replace(/(?<===)[^=]+(?===)/g, 'TestOK');
console.log(transform('aa==1234^&==b'));
Upvotes: 2