Vote count:
0
I am brand new to programming and just getting started in an online program. The problem I am being presented with is: Return a substring between two matching substrings. The string I'm using is: "Violets are blue, the sky is really blue"
I am trying to produce the substring between the two "blue"s. That is: ", the sky is really "
This was one of my attempts which doesn't work. I was trying to slice it using indexOf() and lastIndexOf().
module.exports.substringBetweenMatches = function(text, searchString) { return text.substring(function indexOf(searchString), function lastIndexOf(searchString); }; module.exports.substringBetweenMatches("Violets are blue, the sky is really blue", "blue");
Any suggestions would be appreciated.
asked 28 secs ago
How to return a substring between two matching substrings in JavaScript?
Aucun commentaire:
Enregistrer un commentaire