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
1112660206Måns Grebäck2019-10-21Sweden
224055052Pizzadude - Jakob Fischer2019-10-21Denmark
34667843Johan Waldenström2019-10-21Sweden
43618754Carl Krull2019-10-21Denmark
53252671Fontourist - Hans Gerhard Meier2019-10-21Norway
63020058Johan Aakerlund2019-10-21Denmark
72777598Listemageren - Klaus Johansen2019-10-21Denmark
82511798CheapProFonts - Roger S. Nelsson2019-10-21Norway
92047529HENRIavecunK - Henrik2019-10-21Sweden
101299563Flight of the Dragon - Hasan Guven2019-10-21Norway
111134311Christian Munk2019-10-21Denmark
12762372Adam Ericsson2019-10-21Sweden
14719404Your Own Font - Ellinor Rapp2019-10-21Sweden
15561822Vinterstille TypeFaceLab - Klaus Nielsen2019-10-21Denmark
16512326Viktor Hammarberg2019-10-21Sweden
17489830Moonbase Press - Svein Kåre Gunnarson2019-10-21Norway
18410557Espen Morten Kvalheim2019-10-21Norway
19398526Thor Christopher Arisland2019-10-21Norway
20357714Staffan Vilcans2019-10-21Sweden
21346414Martin Holm2019-10-21Norway
22320489Jonas Borneland Hansen2019-10-21Denmark
23289139Lene Arensdorff2019-10-21Denmark
24238005Norwegian Ink / Design for Dough - Frode Nordbø2019-10-21Norway
25211508David Engelby2019-10-21Denmark
26208570Anton - Anton Lundström2019-10-21Sweden
27200865dawnland - Daniel Viberg2019-10-21Sweden
28181704211178 Creative Agency - Morten Talleivsen2019-10-21Norway
29144024Martin Sørensen2019-10-21Denmark
30121171Andreas Larsen2019-10-21Denmark
31113534Nils Kähler2019-10-21Denmark
32100039Bolahool Graphics2019-10-21Sweden
3490861Joaquim Marquès Nielsen2019-10-21Denmark
3590401Anton Bohlin2019-10-21Sweden
3683071Pär Lundkvist2019-10-21Sweden
3776141Digital Flame Studios - sindre små2019-10-21Norway
3969298Carl Enlund2019-10-21Sweden
4065438huskmelk - Rashid Akrim2019-10-21Norway
4160966Kyrre Honohan2019-10-21Norway
4255711Pia Hed Aspell2019-10-21Sweden
4354601Nadia Rosenfeldt2019-10-21Denmark
4452379Linn Mustanoja2019-10-21Sweden
4551259Lars Håhus2019-10-21Sweden
4645341ronjam - Ronja Melcker2019-10-21Sweden
4742891Atle Mo2019-10-21Norway
4837040Erik Jeddere-Fisher2019-10-21Norway
4934602Arman Ay2019-10-21Sweden
5034285benjamin rauber2019-10-21Sweden
5232368Benjamin Blåholtz2019-10-21Sweden
5329761Studio Indigo - Helena Öhman2019-10-21Sweden
5427623Christian Koch2019-10-21Denmark
5527474Mark Lund2019-10-21Norway
5627295Botond Bokor2019-10-21Sweden
5726928Dan Thorup2019-10-21Denmark
5826300Andrew Nordquist2019-10-21Sweden
6025101Aske Ching2019-10-21Denmark
6122046Erik Holm2019-10-21Norway
6321271Henrik Johansson2019-10-21Sweden
6420989Bull - Sandra Madsen2019-10-21Denmark
6520881David Lindecrantz2019-10-21Sweden
6620093Kristian Dalen2019-10-21Norway
6717430Mandy Pandy2019-10-21Sweden
6814093Alexander Rossebø2019-10-21Norway
6912859Johan Brodd2019-10-21Sweden
7011841Viktor Örneland2019-10-21Sweden
7110097Mathias Alvebring2019-10-21Sweden
747757Mathias Rue2019-10-21Denmark
757318Manuela Hardy2019-10-21Norway
767290Gröt Havregrynsson2019-10-21Sweden
786957Sara Lindberg2019-10-21Sweden
796523Mattis Folkestad2019-10-21Norway
806265Oliver Waldemar2019-10-21Sweden
815277Simon Jakobsson2019-10-21Sweden
824462KingDGaming - Elias Eriksson2019-10-21Sweden

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: