-5

I am working on something that enforces me to clean a String value by retrieving only some specific substring values.

The String follows the following pattern:

param1=value1&param2=value2&param3=value3&param4=value4&param5=value5

I need a solution that retrieves the appropriate values {value1, value2, value3}.

Is there anything ready for this purpose in commans-lang3?

YCF_L
  • 51,266
  • 13
  • 85
  • 129
Soufiane Rabii
  • 377
  • 2
  • 6
  • 27

1 Answers1

3

As suggested in the comments, you may split on & then on = , like this example :

String testString = "param1=value1&param2=value2&param3=value3&param4=value4&param5=value5";

String[] paramValues = testString.split("\\&");

for (String paramValue : paramValues) {

    System.out.println(paramValue.split("\\=")[1]);
}
Arnaud
  • 16,865
  • 3
  • 28
  • 41