Yeah, I'm trying to remove everything except the capital letters, though it doesn't really seem to go well.
I used the following code,
String.replace(/(?![A-Z])./, '');
It doesn't seem to work properly, while it does work using PHP.
Yeah, I'm trying to remove everything except the capital letters, though it doesn't really seem to go well.
I used the following code,
String.replace(/(?![A-Z])./, '');
It doesn't seem to work properly, while it does work using PHP.
Add the global
option at the end of the regex
- see demo below:
console.log("AkjkljKK".replace(/(?![A-Z])./g, ''));
you can use [^A-Z]
to remove everything except capital letters. Also use g
to replace all occurrences and not just the first one.
var str = "sOmeVALUE";
console.log(str.replace(/[^A-Z]/g, ""));