mardi 2 juillet 2019

remove brackets from returned string

I currently call a json within my selenium tests and they are returned in the form of [4534535], id like to remove the brackets and leave just 4534535 but the code im currently using doesnt seem to do that and i cant find a solution.

Currently im using

String[] tmp = response_body_string.split("[\\[\\]]");
String val2 = tmp[0];
val3 = val2.replaceAll("[^0-9]", "");

The response_body_string is what ive received back from the json (please not sometimes theres is a list of code returned thats why im using string[] But it seems to be returning nothing, is the tmp[0] causing the issue?

Aucun commentaire:

Enregistrer un commentaire