Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript get string in string

function betweenMarkers(text, begin, end) {
  var firstChar = text.indexOf(begin) + begin.length;
  var lastChar = text.indexOf(end);
  var newText = text.substring(firstChar, lastChar);
  return newText;
}

console.log(betweenMarkers("MyLongString:StringIWant;",":",";"));
// StringIWant
 
PREVIOUS NEXT
Tagged: #javascript #string #string
ADD COMMENT
Topic
Name
3+5 =