I am using String#replace()
to convert an RGB string into an RGBa one. This is the current code:
inputString = "rgb(255, 182, 121)";
outputString = inputString.replace( "rgb", "rgba" ).replace( ")", ",255)" ).replace( " ", "" );
In the example above, the output will be "rgba(255,182,121,255)"
. This solution, however, looks a bit convoluted, and I think it could be done more elegantly using a regular expression.
How can I write a regular expression (in Java) to accomplish the same thing as the code above?