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
1106282299Måns Grebäck2018-10-17Sweden
222722214Pizzadude - Jakob Fischer2018-10-17Denmark
34508014Johan Waldenström2018-10-17Sweden
43393877Mr.fisk Fonts - Mike Larsson2018-10-17Sweden
53285570Carl Krull2018-10-17Denmark
63220790Fontourist - Hans Gerhard Meier2018-10-17Norway
72708715Listemageren - Klaus Johansen2018-10-17Denmark
82611338Johan Aakerlund2018-10-17Denmark
92400887CheapProFonts - Roger S. Nelsson2018-10-17Norway
101644326HENRIavecunK2018-10-17Sweden
111258762Flight of the Dragon - Hasan Guven2018-10-17Norway
121060715Christian Munk2018-10-17Denmark
13712685Your Own Font - Ellinor Rapp2018-10-17Sweden
14590717bogstav2018-10-17Denmark
15585471Adam Ericsson2018-10-17Sweden
16551217Vinterstille TypeFaceLab - Klaus Nielsen2018-10-17Denmark
17484430Viktor Hammarberg2018-10-17Sweden
18441682Moonbase Press - Svein Kåre Gunnarson2018-10-17Norway
19406098Espen Morten Kvalheim2018-10-17Norway
20350485Staffan Vilcans2018-10-17Sweden
21333448Thor Christopher Arisland2018-10-17Norway
22323843Martin Holm2018-10-17Norway
23314658Jonas Borneland Hansen2018-10-17Denmark
24233646Norwegian Ink / Design for Dough - Frode Nordbø2018-10-17Norway
25205394David Engelby2018-10-17Denmark
26205362Anton - Anton Lundström2018-10-17Sweden
27198030dawnland - Daniel Viberg2018-10-17Sweden
28175873211178 Creative Agency - Morten Talleivsen2018-10-17Norway
29134089Martin Sørensen2018-10-17Denmark
3095220Andreas Larsen2018-10-17Denmark
3195086Bolahool Graphics2018-10-17Sweden
3293849McKack2018-10-17Norway
3392884Nils Kähler2018-10-17Denmark
3489702Joaquim Marquès Nielsen2018-10-17Denmark
3582645Anton Bohlin2018-10-17Sweden
3682541Pär Lundkvist2018-10-17Sweden
3775565Digital Flame Studios - sindre små2018-10-17Norway
3872796Intense2018-10-17Norway
3962986huskmelk - Rashid Akrim2018-10-17Norway
4060456Kyrre Honohan2018-10-17Norway
4154927Pia Hed Aspell2018-10-17Sweden
4253223Nadia Rosenfeldt2018-10-17Denmark
4351421Linn Mustanoja2018-10-17Sweden
4449184Lars Håhus2018-10-17Sweden
4543892ronjam - Ronja Melcker2018-10-17Sweden
4641144Atle Mo2018-10-17Norway
4736104Erik Jeddere-Fisher2018-10-17Norway
4833290charmingfan2018-10-17Denmark
4932472benjamin rauber2018-10-17Sweden
5031664Arman Ay2018-10-17Sweden
5126966Mark Lund2018-10-17Norway
5226062Botond Bokor2018-10-17Sweden
5325897Dan Thorup2018-10-17Denmark
5425875Andrew Nordquist2018-10-17Sweden
5525796Lisa2018-10-17Norway
5624532Aske Ching2018-10-17Denmark
5722367Carl Enlund2018-10-17Sweden
5821653Andreas2018-10-17Sweden
5920642Bull - Sandra Madsen2018-10-17Denmark
6020388Henrik Johansson2018-10-17Sweden
6120364Erik Holm2018-10-17Norway
6220302David Lindecrantz2018-10-17Sweden
6319832Kristian Dalen2018-10-17Norway
6419672Studio Indigo - Helena Öhman2018-10-17Sweden
6517068Mandy Pandy2018-10-17Sweden
6614653Christian Koch2018-10-17Denmark
6713087Alexander Rossebø2018-10-17Norway
6812580Johan Brodd2018-10-17Sweden
6911253Viktor Örneland2018-10-17Sweden
709610Mathias Alvebring2018-10-17Sweden
719443Boksen2018-10-17Norway
727715vardcentralen2018-10-17Sweden
737561Mathias Rue2018-10-17Denmark
746920Manuela Hardy2018-10-17Norway
756640Caesar2018-10-17Sweden
766632Gröt Havregrynsson2018-10-17Sweden
776580Sara Lindberg2018-10-17Sweden
786315Mattis Folkestad2018-10-17Norway
795578Oliver Waldemar2018-10-17Sweden
804980Simon Jakobsson2018-10-17Sweden
814260KingDGaming - Elias Eriksson2018-10-17Sweden

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:

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