I have a giant string as follow obtained from Nokogiri inside a <script> tag:
....com\\/shop\",\"url\":\"?search=espadrille&options=reserve-eligible\",\"slug\":\"options\",\"order\":null,\"matchesMainFilter\":null,\"name\":\"Reserve Eligible\",\"type\":\"options\",\"identifier\":\"reserve-eligible\"}],\"title\":\"Options\",\"identifier\":\"options\",\"remove_url\":\"?search=espadrille\",\"classification\":\"\",\"view_all_url\":\"\",\"count\":\"\",\"slug\":\"\"},{\"children\":[{\"id\":95,\"children\":[{\"id\":150,\"children\":[],\"count\":1,\"applied\":false,\"removeUrl\":\"https:\\/\\/www.fashionphile.com\\/shop\",\"url\":\"?brands=chanel&chanel=lambskin&search=espadrille\",\"slug\":\"lambskin\",\"order\":null,\"matchesMainFilter\":false,\"name\":\"Lambskin\",\"type\":\"brand\"}],\"count\":7,\"applied\":false,\"removeUrl\":\"https:\\/\\/www.fashionphile.com\\/shop\",\"url\":\"?brands=chanel&search=espadrille\",\"slug\":\"chanel\",\"order\":null,\"matchesMainFilter\":false,\"name\":\"Chanel\",\"type\":\"brand\",\"identifier\":\"chanel\"},{\"id\":98,\"children\":[],\"count\":1,\"applied\":false,\"removeUrl\":\"https:\\/\\/www.fashionphile.com\\/shop\",\"url\":\"?brands=louboutin&search=espadrille\",\"slug\":\"louboutin\",\"order\":null,\"matchesMainFilter\":false,\"name\":\"Christian Louboutin\",\"type\":\"brand\",\"identifier\":\"christian-louboutin\"},{\"id\":103,\"children\":[],\"count\":3,\"applied\":false,\"removeUrl\":\"https:\\/\\/www.fashionphile.com\\/shop\",\"url\":\"?brands=gucci&search=espadrille\",\"slug\":\"gucci\",\"order\":null,\"matchesMainFilter\":false,\"name\":\"Gucci\",\"type\":\"brand\",\"identifier\":\"gucci\"},{\"id\":104,\"children\":[],\"count\":1,\"applied\":false,\"removeUrl\":\"https:\\/\\/www.fashionphile.com\\/shop\",\"url\":\"?brands=hermes&search=espadrille\",\"slug\":\"hermes\",\"order\":null,\"matchesMainFilter\":false,\"name\":\"Hermes\",\"type\":\"brand\",\"identifier\":\"hermes\"},{\"id\":107,\"children\":[{\"id\":132,\"children\":[],\"count\":1,\"applied\":false,\"removeUrl\":\"https:\\/\\/www.fashionphile.com\\/shop\",\"url\":\"?brands=louis-vuitton&louis-vuitton=louis-vuitton-monogram&search=espadrille\",\"slug\":\"louis-vuitton-monogram\",\"order\":null,\"matchesMainFilter\":false,\"name\":\"Monogram\",\"type\":\"brand\"}],\"count\":2,\"applied\":false,\"removeUrl\":\"https:\\/\\/www.fashionphile.com\\/shop\",\"url\":\"?brands=louis-vuitton&search=espadrille\",\"slug\":\"louis-vuitton\",\"order\":null,\"matchesMainFilter\":false,\"name\":\"Louis Vuitton\",\"type\":\"brand\",\"identifier\":\"louis-vuitton\"},{\"id\":115,\"children\":[],\"count\":4,\"applied\":false,\"removeUrl\":\"https:\\/\\/www.fashionphile.com\\/shop\",\"url\":\"?brands=valentino&search=espadrille\",\"slug\":\"valentino\",\"order...
I want to find a way to get all the brands=xxxxxx inside an array like ["chanel", "LV"] or maybe a hash {brand1: "chanel", brand2: "LV"}.
--- EDIT ---
And how can I access <meta itemprop=\"brand\" content=\"Chanel\"> and associate it with its <span class=\"sale-price\" itemprop=\"price\" content=\"595.00\">in an array or hash like this:
hash = {chanel: "200", LV: "100"}
Here is the script without data to make it smaller:
<script>
var bootstrappedShopResults = {"products":"<div class=\"container-fluid\">\n <div class=\"product-flex\">\n <\/div>\n<\/div>\n","meta":{"pagination":"","total":0,"itemsFrom":null,"itemsTo":null},"aggregations":[{"children":[],"title":"Price","identifier":"price","remove_url":"?","classification":"","view_all_url":"","count":"","slug":""},{"children":[],"title":"Options","identifier":"options","remove_url":"?","classification":"","view_all_url":"","count":"","slug":""},{"children":[],"title":"Brands","identifier":"brands","remove_url":"?","classification":"","view_all_url":"","count":"","slug":""},{"children":[],"title":"Condition","identifier":"condition","remove_url":"?","classification":"","view_all_url":"","count":"","slug":""}],"parameters":{"pageSize":180,"sort":"date-desc","search":"espadrille.json"},"appliedFilters":[],"mainFilter":null,"pageTitle":"Shop Pre owned Designer Handbags | Used Designer Bags | Fashionphile","metaDescription":"Fashionphile offers a wide selection of pre-owned designer handbags and accessories. Add quality, used designer bags and more to your collection today!","removeSearchUrl":"?pageSize=180&sort=date-desc"};
</script>
nokogirioffer css and xpath selectors which can be much more targeted than string selection. 3) how you went about obtaining this data is paramount to your question as it might lead to far better solutions than your original question of segmenting a string.