I need to enumerate through a string finding all the [ ] and getting the text in between and replacing it all with something different.
For example:
http:\www.domain.com\id=[USER_ID]&record=[CALL_KEY]&someother=[OTHER_STUFF]
As it stands now I have to hard code each individual key and replace it with the value.
private String injectValues(String url) {
    String injected = url.replace("[CALL_KEY]", "123");
    injected = injected.replace("[USER_ID]", "some user ide");
    injected = injected.replace("[OTHER_STUFF]", "somethingElse");
    return injected;
}
I have a bunch of different values that can be plugged in, and instead of hard coding [CALL KEY] etc, I would like to dynamically read what is in there and inject the value.
I have used a RegEx enumerateMatchesInString in Objective-C, is there an Android/Java equivalent?
I have tinkered with Pattern but I don't' know enough about it to make it work for what I want.
private void injectValues(String url) {
        Pattern pattern = Pattern.compile("[(.+?)]");
        Matcher matcher = pattern.matcher(url);
....///EEEEEHH  how do I get the matches?
         String key = ;//THE VALUE INSIDE THE SQUARE BRACKETS
         String aValue = someMethodToGetTheValueForKey(key);
}
 private String someMethodToGetTheValueForKey(String key){
        return "Something";
    }
 
     
    