How to get the substring between two characters in a string with TypeScript

1 Answer

0 votes
const str = "typescript c++ php c java";

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

console.log(subs); 





/*
run:

"escript c++ php " 

*/

 



answered Feb 12, 2022 by avibootz
...