How do I use regex to get a string from a HTML tag

0 favourites
  • 3 posts
From the Asset Store
A collection of a mix of percussion and orchestral string loops, including 20 musical sketches.
  • Hi. I searched for some regex examples and after reading a while my head was about to explode.

    I want to get a string from a html page which is inside a specific tag (but the tag exists multiple times).

    I will need to take some time to dig into it but is there anyone experienced with regex who could help me with this little problem?

    I have html like this:

    [quote:258bnbi6]MORE HTML ABOVE

    <ul>

    <li><a href="//imgur.com/2AtmKfw">Weekly Brawl: SHOW YOUR SUPPORT</a></li>

    <li><a href="//reddit.com/r/Overwatch/comments/4rjn28/patch_1051b_on_pc/">[PC] Patch 1.0.5.1B Notes</a></li>

    </ul></li>

    </ul>

    MORE HTML BELOW

    and the regex should get the text behind "Weekly Brawl: " so I can read the weekly changing brawl from the website to show it in the app. The text is different each week (shorter/longer).

    the href (link) changes everytime too and should be ignored, just the text behind weekly brawl is important.

    Just getting all "li" tags would have too many results so it should just find the line with weekly brawl with a <li> at the start.

    I will try to read more tutorials about it but any help would be very appreciated.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you very much!

    Next step is to get the achievement data.

    It may work with a separate regex action for each achievement but one which gets all of them at once would be much faster/better.

    Any hints or a link to good/easy tutorial for regex would be great.

    The unfinished achievements have the div class "m-disabled" and I need to get all achievements (all lines with "data-tooltip="achievement-"?) and then get the achievement id (data-tooltip) and if it has "m-disabled" as class or not. This should be possible with regex, right?

    Here are 2 examples from the code:

    <div class="column xs-6 sm-6 md-4 lg-3 xl-2"><div class="media-card m-hoverable m-clickable u-margin-bottom-md" data-tooltip="achievement-0x0E60000000000192"><div class="container"><img class="media" src="https://blzgdapipro-a.akamaihd.net/game/achievements/0x0E60000000000192.png"><div class="content">The Friend Zone</div></div></div><div class="tooltip-media-card" id="achievement-0x0E60000000000192"><span class="arrow"></span><h6 class="h5">The Friend Zone</h6><p class="h6">Play a Quick or Competitive Play game in a group with a friend.</p></div></div>
    
    <div class="column xs-6 sm-6 md-4 lg-3 xl-2"><div class="media-card m-disabled m-clickable u-margin-bottom-md" data-tooltip="achievement-0x0E6000000000015E"><div class="container"><img class="media" src="https://blzgdapipro-a.akamaihd.net/game/achievements/0x0E6000000000015E.png"><div class="content">The Path Is Closed</div></div></div><div class="tooltip-media-card" id="achievement-0x0E6000000000015E"><span class="arrow"></span><h6 class="h5">The Path Is Closed</h6><p class="h6">Destroy 3 of Symmetra's Teleporters in a single Quick or Competitive Play game.</p></div></div>[/code:3t6jc4j4]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)