How to get the substring between two characters in a string with Node.js

1 Answer

0 votes
const str = "nodejs node.js c++ php c java";

const subs = str.slice(
  str.indexOf('e') + 1,
  str.lastIndexOf('c'),
);

console.log(subs); 





/*
run:

js node.js c++ php  

*/

 



answered Feb 12, 2022 by avibootz
...