javascript - Grabbing only the YAML text from a file in JS -


suppose have file has random text mixed yaml text. yaml text between --- , ....

goal: goal take string (taken such file):

--- some: "yaml" some: "more yaml" ...  random text that's not yaml.  --- more: "yaml" ... 

and output string contains only yaml parts (including --- , ... delimiters):

--- some: "yaml" some: "more yaml" ...     --- more: "yaml" ... 

how 1 this?

this can done string.prototype.match + array.prototype.join:

function extractyaml(string) {     return string.match(/(---(.|\n)*?\.\.\.\n)/g).join(''); } 

Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -