简体   繁体   中英

Regex for home automation

I am trying to split a feedback response from a Bluesound Node 2i, but I am struggling to work out how to achieve this. The software only accepts one capture group, the format of the response is x the number of presets (10 in my case) eg

preset url="TuneIn:s83457/http://opml.radiotime.com/Tune.ashx?id=s83457&formats=wma,mp3,aac,ogg,hls&partnerId=8OeGua6y&serial=E8:9F:80:5F:89:72" id="1" name="BBC Radio 1 98.2 (Top 40 & Pop Music)" image="http://cdn-radiotime-logos.tunein.com/s24939q.png"/

I need to match " id="1" name=" so I know which preset it applies to but then I want to capture the image url http://cdn-radiotime-logos.tunein.com/s24939q.png I have used " id="1" name="(.*?)" to capture the name of the preset but I am struggling to workout how to capture the image text

here is one way to capture id=1 and image

(id=\"1\")\s.*(image=.*)

在此处输入图像描述

if you need to capture just one group ie, image, then use the following

(?:id=\"1\")\s.*(image=.*)

在此处输入图像描述

image URL only

(?:id=\"1\")\s.*image=\"(.*)\"

在此处输入图像描述

you can test it here https://regex101.com/r/t8mMrl/1

does it help?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM