remove text from string code example

Example 1: How to remove text from a string in javscript

var ret = "data-123".replace('data-','');
console.log(ret);   //prints: 123

Example 2: js remove string from string

var ret = "data-123".replace('data-','');
console.log(ret);   //prints: 123

Example 3: how to remove letters from string

public extractLetters(String str){
	String result="";
	for(int i= 0; i< str.length; i++){
	    if(Character.isLetter(str.charAt(i))){
	    result+=str.charAt(i);
	  	}
	}

Example 4: how to remove a text by javascript

var ret = "data-123".replace('data-','');

Tags:

Java Example