As clarified in comments, you seem to be looking to replace the last placeholder that appears after a slash /. For this you can use following regex,
[^/]+$
Here, [^/] is a negated character class which captures any character except a slash / and + means one or more characters and $ means end of string which will ensure this will match any text that appears in end of string not containing /. So just match using it and replace with xyz or any string of your choice.
Demo
Java code,
List<String> list = Arrays.asList("/test/data/{id}/moreData/{id}","/test/data/{id}/moreData/{objId}","/test/data/{id}/moreData/{anything else}");
list.forEach(x -> System.out.println(x + " --> " + x.replaceAll("[^/]+$", "xyz")));
Prints,
/test/data/{id}/moreData/{id} --> /test/data/{id}/moreData/xyz
/test/data/{id}/moreData/{objId} --> /test/data/{id}/moreData/xyz
/test/data/{id}/moreData/{anything else} --> /test/data/{id}/moreData/xyz