mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-01 01:12:39 +00:00
13 lines
No EOL
460 B
JavaScript
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 }; |