I'm writing a little web service which generates SO/SF/SU/MSO user flair in the form of an image with various "themes". I find this preferable to using the HTML/JS solutions offered by SO as it's more flexible and also works better in forum signatures.
I'm retrieving the data using the apparently unofficial API (More info here). I can have the data in HTML or JSON. I assumed the JSON would be easier to parse.
Unfortunately, I'm not great at regexes. and the best I can come up with is some very hacky sub-stringing. I believe a regex should be the most elegant solution but would welcome other suggestions.
Can someone please point me in the right direction for a regex that matches ID, GravatarURL, ProfileURL, DisplayName, Reputation and Badge Counts (Bronze/Silver/Gold).
FWIW This is to be used in a VB.Net project (in case that affects the syntax at all)
{"id":1,"gravatarHtml":"\u003cimg src=\"http://www.gravatar.com/avatar/51d623f33f8b83095db84ff35e15dbe8?s=50&d=identicon&r=PG\" height=\"50\" width=\"50\" alt=\"\"\u003e","profileUrl":"http://stackoverflow.com/users/1/jeff-atwood","displayName":"Jeff Atwood","reputation":"18,446","badgeHtml":"\u003cspan title=\"8 gold badges\"\u003e\u003cspan class=\"badge1\"\u003e●\u003c/span\u003e\u003cspan class=\"badgecount\"\u003e8\u003c/span\u003e\u003c/span\u003e\u003cspan title=\"57 silver badges\"\u003e\u003cspan class=\"badge2\"\u003e●\u003c/span\u003e\u003cspan class=\"badgecount\"\u003e57\u003c/span\u003e\u003c/span\u003e\u003cspan title=\"72 bronze badges\"\u003e\u003cspan class=\"badge3\"\u003e●\u003c/span\u003e\u003cspan class=\"badgecount\"\u003e72\u003c/span\u003e\u003c/span\u003e"}
or a slightly more readable format:
{
"id":1,
"gravatarHtml":"\u003cimg src=\"http://www.gravatar.com/avatar/51d623f33f8b83095db84ff35e15dbe8?s=50&d=identicon&r=PG\" height=\"50\" width=\"50\" alt=\"\"\u003e",
"profileUrl":"http://stackoverflow.com/users/1/jeff-atwood",
"displayName":"Jeff Atwood",
"reputation":"18,446",
"badgeHtml":"
\u003cspan title=\"8 gold badges\"\u003e\u003cspan class=\"badge1\"\u003e●\u003c/span\u003e\u003cspan class=\"badgecount\"\u003e8\u003c/span\u003e\u003c/span\u003e
\u003cspan title=\"57 silver badges\"\u003e\u003cspan class=\"badge2\"\u003e●\u003c/span\u003e\u003cspan class=\"badgecount\"\u003e57\u003c/span\u003e\u003c/span\u003e
\u003cspan title=\"72 bronze badges\"\u003e\u003cspan class=\"badge3\"\u003e●\u003c/span\u003e\u003cspan class=\"badgecount\"\u003e72\u003c/span\u003e\u003c/span\u003e
"
}
(NB: It's worth noting that if you don't have any of a certain badge, there's no entry for that badge at all rather than showing a "0")
Unfortunately, I don't even know where to start with the regex so any help, suggestions or documentation greatly appreciated
[Edit]
In case any of you are interested, some screenshots of the flair as a work in progress are available here: Me, Jeff Atwood, Joel Spolsky
I'll make it publicly accessible if anyone wants their own?
[/Edit]