0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-23 03:35:15 +00:00
VueTube/NUXT/plugins/utils.js
2022-03-17 08:47:17 +13:00

13 lines
No EOL
460 B
JavaScript

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