Randall Munroe's (from xkcd) newest idea
kolodny.github.io
Randall Munroe's (from xkcd) newest idea
1–4 of 4 posts
Re: Randall Munroe's (from xkcd) newest idea
#2Time to find a text version of cspan
Re: Randall Munroe's (from xkcd) newest idea
#3Someone posted similar js when this xkcd was discussed yesterday (https://news.ycombinator.com/item?id=6696355), but also missed that js lets you grab nodesets using xpaths directly:
var snap = document.evaluate('//text()',
document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i=0;i
In addition your code uses \s\s* when you just mean \s+; also you are using case-insensitive matches for the 'dictRegex' pattern with case-sensitive matches for the individual patterns, so you replace eg 'election' (lower case e) with 'undefined'.Like the other js implementation you're not matching word boundaries (\b).
Re: Randall Munroe's (from xkcd) newest idea
#4Someone posted similar js when this xkcd was discussed yesterday ( https://news.ycombinator.com/item?id=6696355 ), but also missed that js lets you grab nodesets using xpaths directly: var snap = document.evaluate('//text()', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (var i=0;i In addition your code uses \s\s* when you just mean \s+; also you are using case-insensitive matches for the 'dictRe…
Thanks for the ignoreCase problem, I fixed it. I actually was using a \b in the link but forgot to update the source accordingly. The reason I use \s\s* over \s+ is because I once saw that it has some performance benefits, although it really doesn't make a difference