For example, the input would be:
@[facts.::ip](facts.::ip) = "127.0.0.1" AND @[facts.::os](facts.::os) = "ubuntu"
I would like to transform that into:
facts.::ip = "127.0.0.1" AND facts.::os = "ubuntu"
Thanks in advance!
I have tried to check for regex, but I do not have experience with it
Advertisement
Answer
Below regular expression method achieves required string transformation.
JavaScript
x
3
1
let from = '@[facts.::ip](facts.::ip) = "127.0.0.1" AND @[facts.::os](facts.::os) = "ubuntu"';
2
let to = from.replace(/(@[([^])]+)](2))/g, "$2");
3
console.log(to);