xxxxxxxxxx
Remove the first or last charachter of a String
xxxxxxxxxx
String string = "Hello World";
//Remove first character
string.substring(1); //ello World
//Remove last character
string.substring(0, string.length()-1); //Hello Worl
//Remove first and last character
string.substring(1, string.length()-1); //ello Worl
xxxxxxxxxx
String roles = "[This is an example of list.toString()]";
//Below substring method will remove the first and last character of roles String
roles = roles.substring(1, roles.length()-1);
// here roles will become "This is an example of list.toString()"
System.out.println("New String: "+roles);
xxxxxxxxxx
<?php
$str = "geeks";
// Or we can write ltrim($str, $str[0]);
$str = ltrim($str, 'g');
echo $str;
?>
xxxxxxxxxx
String data = "/culo"
data.Remove(0,1);
data.TrimStart('/');
data.Substring(1);