0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-23 11:45:15 +00:00
VueTube/NUXT/plugins/utils.js

13 lines
460 B
JavaScript
Raw Normal View History

// Collection of functions that are useful but non-specific to any particular files
function getBetweenStrings(data, start_string, end_string) {
2022-03-16 19:47:17 +00:00
const regex = new RegExp(`${escapeRegExp(start_string)}(.*?)${escapeRegExp(end_string)}`, "s");
const match = data.match(regex);
return match ? match[1] : undefined;
}
2022-03-16 19:47:17 +00:00
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
module.exports = { getBetweenStrings };