I have worked in a SOAP message to get the LoginToken from a Webservice, and store that LoginToken as a String. U used System.out.println(LoginToken);
to print the value. This prints [wdsd34svdf]
, but I want only wdsd34svdf
. How can I remove these square brackets at the start and end of the output?
Example:
String LoginToken=getName().toString(); System.out.println("LoginToken" + LoginToken);
The output is: [wdsd34svdf]
.
I want just wdsd34svdf
The idea is to use the deleteCharAt() method of StringBuilder class to remove first and the last character of a string. The deleteCharAt() method accepts a parameter as an index of the character you want to remove.
In Excel 2013 and later versions, there is one more easy way to delete the first and last characters in Excel - the Flash Fill feature. In a cell adjacent to the first cell with the original data, type the desired result omitting the first or last character from the original string, and press Enter.
You need to find the index of [
and ]
then substring
. (Here [
is always at start and ]
is at end):
String loginToken = "[wdsd34svdf]"; System.out.println( loginToken.substring( 1, loginToken.length() - 1 ) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With