I have a web page that generates links for keywords. The links get generated on the web page like so:
https://www.example.com/?keywords=energy
https://www.example.com/?keywords=wind%20power
I'd like to change it so that the first character after the =
(and the %20
when applicable) is uppercase:
https://www.example.com/?keywords=Energy
https://www.example.com/?keywords=Wind%20Power
Currently, I have been changing them to uppercase on a per keyword basis:
$(document).ready(function(){
$('a').each(function(){
this.href = this.href.replace('energy', 'Energy');
});
$('a').each(function(){
this.href = this.href.replace('wind%20power', 'Wind%20Power');
});
});
Is there a way to do this, but with any string? I've tried several regular expressions but cannot seem to find a regex for replacing the first character after the equals sign with its uppercase equivalent using javascript. For example I tried this (https://regex101.com/r/ybQbaE/1/), and then tried to dump it into my script on the page:
`$(document).ready(function(){
$('a').each(function(){
this.href = this.href.replace(\=.,\U$0);
});
});`
Of course it didn't work because it's for PHP, but when I click on the ECMAscript Flavor on the regex tester it just replaces the equals sign and the first character after it with \U$0
.