I would like to know if there is a proper way to replace a substring that is preceded by $. For instance, if we have strings that look like:
String s = "something variable = $firstname something something"; or
String s = "something foo($firstname) something else";
I would like to replace all occurences of a "variable"(i.e is preceded by $), in this case, $firstname with 'x' (including the single quotes). So we should end up with the result:
String s = "something variable = 'x' something something"; or
String s = "something foo('x') something else";
But I'm not sure how to write a proper regex that can do this.