Search code examples
regextextcapture

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) e.g.

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


Solution

  • here is one way to capture id=1 and image

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

    enter image description here

    if you need to capture just one group i.e., image, then use the following

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

    enter image description here

    image URL only

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

    enter image description here

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

    does it help?