HISE regex is wierd - how to select HTML tags?
-
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.
-
@Christoph-Hart Any ideas? Also can the
.replace()
function use regex? -
Yes, that's correct, I've fixed it now so it will find all matches and not just the first one.
-
Also can the .replace() function use regex?
No and the syntax for regex replacement is so ugly I can't even look at it...
-
@Christoph-Hart Thank you!
-
I see you're having fun with the code comments today :)
-
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));