how to get string between two characters in javascript code example
Example 1: javascript get string between two characters
const oldString = 'John1Doe2'
const stringBetweenCharacters = oldString.match(/1(.*?)2/i)[1] //Doe
Example 2: how to count specific letters in string js
console.log(("str1,str2,str3,str4".match(/,/g) || []).length); //logs 3
console.log(("str1,str2,str3,str4".match(new RegExp("str", "g")) || []).length); //logs 4