java substring w3schools code example
Example 1: java substring
String s = "Let's Get This Bread";
String subString = s.substring(6, 9);
// (start index inclusive, end index exclusive)
// subString == "Get"
Example 2: js .substring
let anyString = 'Mozilla'
// Displays 'M'
console.log(anyString.substring(0, 1))
console.log(anyString.substring(1, 0))
// Displays 'Mozill'
console.log(anyString.substring(0, 6))
// Displays 'lla'
console.log(anyString.substring(4))
console.log(anyString.substring(4, 7))
console.log(anyString.substring(7, 4))
// Displays 'Mozilla'
console.log(anyString.substring(0, 7))
console.log(anyString.substring(0, 10))
Example 3: javascript substring
// zero-based index, 'end' is excluded from result
myString.substring( start, end )
Example 4: substring java
import java.lang.*;
public class StringDemo {
public static void main(String[] args) {
String str = "This is tutorials point";
String substr = "";
// prints the substring after index 8 till index 17
substr = str.substring(8, 17);
System.out.println("substring = " + substr);
// prints the substring after index 0 till index 8
substr = str.substring(0, 8);
System.out.println("substring = " + substr);
}
}
Example 5: java sstring
//string syntax.
String hello = "Hello, world!";
Example 6: cut string from string javascript
var ret = "data-123".replace('data-','');
console.log(ret); //prints: 123