-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?

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
Soufiane Rabii
  • 427
  • 2
  • 8
  • 29

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
  • 17,229
  • 3
  • 31
  • 44