Extract the text out of HTML string using JavaScript

Create an element, store the HTML in it, and get its textContent: function extractContent(s) { var span = document.createElement(‘span’); span.innerHTML = s; return span.textContent || span.innerText; }; alert(extractContent(“<p>Hello</p><a href=”http://w3c.org”>W3C</a>”)); Here’s a version that allows you to have spaces between nodes, although you’d probably want that for block-level elements only: function extractContent(s, space) { var span= … Read more

Stroke Width Transform (SWT) implementation (Java, C#…) [closed]

My friend Andrew and I implemented Stoke Width Transform (SWT) on a mobile phone during a class project at Cornell. Maybe you can get hint from the report. The report: http://www.cs.cornell.edu/courses/cs4670/2010fa/projects/final/results/group_of_arp86_sk2357/Writeup.pdf Our code: https://sites.google.com/site/roboticssaurav/strokewidthnokia Updated code: https://github.com/aperrau/DetectText

How do you extract a url from a string using python?

There may be few ways to do this but the cleanest would be to use regex >>> myString = “This is a link http://www.google.com” >>> print re.search(“(?P<url>https?://[^\s]+)”, myString).group(“url”) http://www.google.com If there can be multiple links you can use something similar to below >>> myString = “These are the links http://www.google.com and http://stackoverflow.com/questions/839994/extracting-a-url-in-python” >>> print re.findall(r'(https?://[^\s]+)’, … Read more