I'm trying to fetch file contents with help of nodejs fs.readFileSync() function into string like this:
let fileData = fs.readFileSync('./path, 'utf8');
after this I want to get the contents between two string through regex:
I've a string something like this:
<route-meta>
{
"requiresAuth": true
}
</route-meta>
<template>
</template>
<script>
export default {
name: "check"
}
</script>
<style scoped>
</style>
I need to find text/string between <route-meta> and </route-meta> so that the result should be:
{
"requiresAuth": true
}
I tried doing this with fileData.match(/<route-meta>(.*?)<\/route-meta>/); but somehow it is giving me null result
I followed through this example: Regex match text between tags
Also I tried to check fileData.replace('route-meta', ''); but still it is giving me no desired result I mean I'm unable to do any string operations with fileData.
Guide me where I'm doing mistake.