This is my vue code
<template>
<a href="#" class="block relative">
<img alt="profil" src="https://www.tailwind-kit.com/images/person/1.jpg" class="mx-auto object-cover rounded-full h-16 w-16 "/>
</a>
</template>
<script>
export default
{
name: 'code' ,
data() { return {} } ,
created(){},
methods: {}
}
</ script>
now I treat this code as a whole string, i want to extract the code from "< template > ".
i tried to use regex,
function getStringBetween(str, start, end) {
const result = str.match(new RegExp(start + "(.*)" + end));
return result[1];
}
let test = str.match(new RegExp('<template>' + "(.*)" + '</template>'));
console.log('transferHtml',test);
but the result shows null, any other way to extract the string between certain strings ?