Forum

    • Register
    • Login
    • Search
    • Categories

    HISE regex is wierd - how to select HTML tags?

    General Questions
    2
    7
    171
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d.healey
      d.healey last edited by

      I want to select all html tags in a string. Normally the regex for this would be <[^<>]+>

      But this doesn't work with getRegexMatches()

      Any suggestions?

      HiseSnippet 751.3ocsUstaSCCE1tqAQKWDShG.q9GZEitVXLPZkxXcsPErspkwDRHXxKws0ZI1Q1NiUgP7Jya.bbRVuvpJaUh7i1bt7Y+4i+NmzSI8XZsTgvENZTDCguqi6HgYXqgTt.0cWD99N6Q0Flhj5ZmQQTsl4iv3Udq0AtPdTxyud8Nz.pviMwEBcrj6w9.Ojal3s21umGDzg5yNhGNU1arcWOonkLPFC7YEmZnHp2YzAr8o1zx4fv2psO2HUtFpgogb1Q5Oxcn7ahz7Olq4mFvrF0QtvBk5F0ZHOvu2kmUMBgy2axIekzS9Cc1i6yG6eRE3AIAHSPLcM.maQTp9MfR3onT9TJspiqmhGYlDwxm63zU.WH8oPodZpjlKJ2OwNsjPFBS0P5YrNJvXLhxaVq1ZD3mJaUrHTt0FhTwGvEz.WihKFPdEoTQBogO+7lv+vaQMeGaDwLjZdjlzPGQEM0xPyPH4FqmX1X8HatMVOATowqbH03Mjogkrs.1BV0ALygrArK1KMP4Y250HkZ74u1n4WdbyRV5AmBsLfUMBBZJaTV5msjUprU+XgmgKEDoXeogcfnbkheuXgh+nH4uC0u+biYqRJYP.SM2vV0oZQ.KKhCOkoVibNMHlMNQ35aVMwstdZBuzKsoRTJ5J3lChXY1cjA916Z66WUAgxt0g29X2coFpUTk4CxKhoLbKcv6xNG5JSkXEb1koOyHif9xqn+.kuzONfZlscv12mE.pGynAs5LglaFM8bgaPORsE1ibco3pN83fLY9bL2b3HTo9evwrIK2yoc+9LOyDBl2oymV1wH+is+PYrA5kfNLE+BD1Y+3PWXfpGC1cgfE.KtCNmUsjZWyZaq.tLgehwugmrf0s13rf0uLHJj5ojm3k1EXmcc6DO.mDIipK.ey.rI0QIcF.NmZUqgBgwnm34YO9OADvyGySWBLOaIvrwRf44KAlMWBLuXIv7xEhw9Er2DajgosCfidsSFQfwsETPYknBQ+AC4DMs.
      

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      1 Reply Last reply Reply Quote 0
      • d.healey
        d.healey last edited by

        @Christoph-Hart Any ideas? Also can the .replace() function use regex?

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        Christoph Hart 1 Reply Last reply Reply Quote 0
        • Christoph Hart
          Christoph Hart @d.healey last edited by

          Yes, that's correct, I've fixed it now so it will find all matches and not just the first one.

          Christoph Hart 1 Reply Last reply Reply Quote 1
          • Christoph Hart
            Christoph Hart @Christoph Hart last edited by

            Also can the .replace() function use regex?

            No and the syntax for regex replacement is so ugly I can't even look at it...

            d.healey 1 Reply Last reply Reply Quote 1
            • d.healey
              d.healey @Christoph Hart last edited by

              @Christoph-Hart Thank you!

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              1 Reply Last reply Reply Quote 0
              • d.healey
                d.healey last edited by

                I see you're having fun with the code comments today 🙂

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                1 Reply Last reply Reply Quote 0
                • d.healey
                  d.healey last edited by d.healey

                  Here's a function for stripping html tags from a string.

                  const originalString = "
                    <div>
                      <p>Hey that's <span>something</span></p>
                    </div>
                  ";
                  
                  inline function stripHtmlTags(str)
                  {
                  	local newString = str;
                  	local matches = Engine.getRegexMatches(newString, "<[^<>]+>");
                  
                  	for (x in matches)
                  		newString = newString.replace(x);
                  		
                  	return newString.trim();
                  }
                  
                  Console.print(stripHtmlTags(originalString));
                  

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  1 Reply Last reply Reply Quote 4
                  • First post
                    Last post

                  16
                  Online

                  1.1k
                  Users

                  6.8k
                  Topics

                  62.3k
                  Posts