1
2
3
4
5
6
| // The following code works fine in Chrome but throws an error in Safari.
"https://linlccc.com?theme=light".replace(/(?<=[?|&]theme=)\w+/, "dark");
// The solution is to use capturing groups and string replacement.
"https://linlccc.com?theme=light".replace(/([?|&]theme=)\w+/, "$1dark");
// Both of the execution results above are "https://linlccc.com?theme=dark"
|