Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2363

Re: core_course_get_courses course summary value

$
0
0

by Matt Perkins.  

Sure! smile I typed up this example in the editor so I can't garuntee they'll work 100%, but the functions below are what I'm using. I can't take credit for the Regex, I think I found it on stackoverflow a while back.


// Example

var summary = "<h1>Some title</h1><p>This is <span>&gt;cool!&lt;</span></p>"

var cleanedSummary = removeEntity(removeTags(summary));

// cleanedSummary will be "Some title This is cool!"



// Remove all HTML tags from a string

function removeTags(str) {

  return str.replace(/(<([^>]+)>)/ig, '');

}


// Remove all HTML entities such as &gt; &nbsp;

function removeEntity(str) {

  return str.replace(/(&(#?)(?:[a-z\d]+|#\d+|#x[a-f\d]+);)/ig, '');

}


Viewing all articles
Browse latest Browse all 2363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>