I want to create a regex expression that generates a match and strips off the $, and the last two characters, if the last character ends in a capital letter plus a number.
I'll strip off the $ and then an ending capital letter + number:
$mytestA1 --> expected output: mytest
$againD4 --> expected output: again
$something --> expected output: something
$name3 --> expected output: name3 // because there was no capital letter before the number digit
$name2P4 --> expected output: name2
I’ll have an ‘if’ check in my code that checks for the existence of a $ before I would even bother to run the regex.
Thanks.
In Java just use String#replaceAll: