Fontstats Plugin

Today I finished a little WordPress plugin I’ve been working on.

It’s a two part plugin, one php script collects data from any Norwegian designer on DaFont by visiting each site, and by the power of Regex-Grayskull it inserts it into a database on my website.

The WordPress plugin then selects the last sampled date and displays it in a HTML-table on any post or page where I insert the registered shortcode.

Here’s the result:

No.DownloadsDesignerDate SampledCountry
1111726091Måns Grebäck2019-08-22Sweden
223829630Pizzadude - Jakob Fischer2019-08-22Denmark
34631515Johan Waldenström2019-08-22Sweden
43563682Carl Krull2019-08-22Denmark
53248088Fontourist - Hans Gerhard Meier2019-08-22Norway
62947318Johan Aakerlund2019-08-22Denmark
72765772Listemageren - Klaus Johansen2019-08-22Denmark
82493554CheapProFonts - Roger S. Nelsson2019-08-22Norway
91989785HENRIavecunK - Henrik2019-08-22Sweden
101292424Flight of the Dragon - Hasan Guven2019-08-22Norway
111123186Christian Munk2019-08-22Denmark
12735187Adam Ericsson2019-08-22Sweden
13723553bogstav2019-08-22Denmark
14718414Your Own Font - Ellinor Rapp2019-08-22Sweden
15560123Vinterstille TypeFaceLab - Klaus Nielsen2019-08-22Denmark
16507905Viktor Hammarberg2019-08-22Sweden
17482087Moonbase Press - Svein Kåre Gunnarson2019-08-22Norway
18409878Espen Morten Kvalheim2019-08-22Norway
19390980Thor Christopher Arisland2019-08-22Norway
20356411Staffan Vilcans2019-08-22Sweden
21342911Martin Holm2019-08-22Norway
22319772Jonas Borneland Hansen2019-08-22Denmark
23237275Norwegian Ink / Design for Dough - Frode Nordbø2019-08-22Norway
24210555David Engelby2019-08-22Denmark
25208043Anton - Anton Lundström2019-08-22Sweden
26200435dawnland - Daniel Viberg2019-08-22Sweden
27180714211178 Creative Agency - Morten Talleivsen2019-08-22Norway
28142448Martin Sørensen2019-08-22Denmark
29116045Andreas Larsen2019-08-22Denmark
30109786Nils Kähler2019-08-22Denmark
3199123Bolahool Graphics2019-08-22Sweden
3294700McKack2019-08-22Norway
3390691Joaquim Marquès Nielsen2019-08-22Denmark
3489126Anton Bohlin2019-08-22Sweden
3582978Pär Lundkvist2019-08-22Sweden
3676055Digital Flame Studios - sindre små2019-08-22Norway
3773492Intense2019-08-22Norway
3865077huskmelk - Rashid Akrim2019-08-22Norway
3960856Kyrre Honohan2019-08-22Norway
4059160Carl Enlund2019-08-22Sweden
4155592Pia Hed Aspell2019-08-22Sweden
4254389Nadia Rosenfeldt2019-08-22Denmark
4352262Linn Mustanoja2019-08-22Sweden
4450916Lars Håhus2019-08-22Sweden
4545107ronjam - Ronja Melcker2019-08-22Sweden
4642630Atle Mo2019-08-22Norway
4736892Erik Jeddere-Fisher2019-08-22Norway
4834126Arman Ay2019-08-22Sweden
4933989benjamin rauber2019-08-22Sweden
5033544charmingfan2019-08-22Denmark
5128696Studio Indigo - Helena Öhman2019-08-22Sweden
5228204Benjamin Blåholtz2019-08-22Sweden
5327403Mark Lund2019-08-22Norway
5427096Botond Bokor2019-08-22Sweden
5526768Dan Thorup2019-08-22Denmark
5626227Andrew Nordquist2019-08-22Sweden
5725938Lisa2019-08-22Norway
5825024Aske Ching2019-08-22Denmark
5924732Christian Koch2019-08-22Denmark
6021921Andreas2019-08-22Sweden
6121756Erik Holm2019-08-22Norway
6221143Henrik Johansson2019-08-22Sweden
6320935Bull - Sandra Madsen2019-08-22Denmark
6420784David Lindecrantz2019-08-22Sweden
6520050Kristian Dalen2019-08-22Norway
6617369Mandy Pandy2019-08-22Sweden
6713784Alexander Rossebø2019-08-22Norway
6812807Johan Brodd2019-08-22Sweden
6911749Viktor Örneland2019-08-22Sweden
7010011Mathias Alvebring2019-08-22Sweden
719723Boksen2019-08-22Norway
727909vardcentralen2019-08-22Sweden
737727Mathias Rue2019-08-22Denmark
747265Manuela Hardy2019-08-22Norway
757172Gröt Havregrynsson2019-08-22Sweden
766932Caesar2019-08-22Sweden
776900Sara Lindberg2019-08-22Sweden
786486Mattis Folkestad2019-08-22Norway
796149Oliver Waldemar2019-08-22Sweden
805219Simon Jakobsson2019-08-22Sweden
814431KingDGaming - Elias Eriksson2019-08-22Sweden

Regex 101

Today I received an email from the store I used to work at asking me to make a printer friendly version of an online table of information.

As I learned more about regular expressions from the “INF3331” course I took this fall, solving this problem proved to be way easier than any previous attempts at the likes of it.

At times I’ve thought that regexes are harder to read and debug than ordinary programming languages, but with a good editor like Atom or the regex101 page, it all became a lot less stressful.

As far as editors go, I have to admit that I still use emacs when I’m not using an IDE or GUI-editor.

Note to self about regular expressions.

(.*?) to capture zero or more characters in a non-greedy manner

(?:.*?) for the same grouping without backreferences.

$1 or $[group-number] for backreferences in JavaScript and Atom

\1 or \[group-number] for backreferences in Python, PHP.

Perl and PHP also uses \g1 or \g[group-number] for backreferences.

The following characters need to be escaped in regex:

.^$*+?()[{\|