I need to retrieve a specific content like this "{ content }" in my svg file
So I think I need to use a regex but i don't know how to do
test.svg
<svg width="500" height="100">
<text x="47.872" y="11.064" id="smartCar">{garage/temp} °C</text>
<circle id="circle1" cx="20" cy="20" r="10"
style="stroke: none; fill: #ff0000;"/>
<text x="47.872" y="11.064" id="smartCar">{home/sensors/temp/kitchen} °C</text>
</svg>
findContent.js
var fs = require('fs');
const fileContent = fs.readFileSync( "test.svg","UTF-8");
const lines = fileContent.split("\n");
console.log(lines);
lines.forEach((line) => {
const topicMatch = line.match(); //need regex
if (topicMatch) {
console.log(topicMatch[1]) // display all content with syntax {content}
}
})
Expected result:
- {garage/temp}
- {home/sensors/temp/kitchen}