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
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)
[Code].....
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
how to parse and extract specific elements out of a JSON that I obtain from a web source. Using Visual Studio 2010 and VB. I can get the JSON but I haven't been able to find any examples or tutorials regarding parsing the data, locating specific elements and their associated data.
I'm sure this has been asked before but I'm not finding quite the information I'm needing so I thought I'd post this.
I've written a PHP script that returns a simple JSON object that looks like this:
{"status":"success","level":"admin"}
I'm doing a standard web request that submits the required data to the script over the internet and that's working fine.
Now, I want to use JSON.NET to pull out the individual variables so I can know what the values of "status" and "level" are. The problem is, I have no idea where to start.
I'm doing this in VB.NET (on the .NET Compact Framework).
I am trying to remove the tables within an HTML file, specifically, for the following document, I'd like to remove anything within the tags <TABLE....> and </TABLE>. The document contains multiple tables with texts in between.
The expression that I came up with, <TABLE.*>s*[s|S]*</TABLE>s*, however would remove the text in between the tables. In fact it would remove everything between the first <TABLE> and the last </TABLE> tags. I would like to keep the texts in between and only remove the tables.
Some things with the file are standard, like the "TableName" (Never in quotes) starts the table. Variables always have [" "] around them and then equal something like ["Test"] = 0. However, the variable could have multiple variables within it. split up the file within each {} and then try to parse each ["QuotedString-Key"] = 0?
I've used regular expressions in the past. I have an app that parses a .csv file and replaces certain characters (commas). Here's an example.. item1, item2, item3, fruits are apples, oranges, grapes. Squash is a vegetable, not a fruit. What my app does is search each line between character1 and character18 and replace all "," with "~". How this is done through regular expressions?
I was hoping someone may be able to point me in the right direction in regards to the format of a Json.I've never really worked with Json's and Serialization before so it's all a little new.I need to return a Json from .Net in the following format.[[Date.UTC(2011,12,14,8), 8], [Date.UTC(2011,12,14,9), 1]]
I'm almost there but am struggling with the format of my string, as by default the string is quoted. This is what I have:
I'm a newbie about web services in VB.NET. I'm making a desktop application that will talk to JIRA[URL]..They provided a REST api that I decided to use. The first step is to login which they say that...
"To log in to JIRA, you need to POST a username and password in JSON format..." {"username" : "admin", "password" : "admin"} to this url... https://addressgoeshere (we are using https)
Can someone provide me a sample code to do this so I can have a guide and a good start?
I have a string which i need to parse using Regex class of System.Text.RegularExpressions. I need to find if the first 2 characters of the string are either "00" or "07" or "16" or "23".
Problem: Current regex pattern does not filter all lines. Adding ^ to the beginning and $ to the ending of the pattern seems to break it as well. If I try it ont gives partial results using options(multiline & case insensitive). Using it in the application returns nothing at all.
I'm attempting to parse a text file containing several Windows paths; I'd like to use regular expressions if possible, and I'm using VB.NET.The file is formatted somewhat like so:
M - Network Mode C:ClientSystem - System Path C:ClientProducts - Product Path
this is the JSON string the data is required in to be sent using a given URL.[code]I am using VB.net and i need to create this string using VB.net. I tried using namevaluecollection and doing a POST. I also tried making a string and send data using GET. Both failed. how can i do this?
Part of my project is to retrieve a string variable from an external source (google docs) and parse it. This string represents width and height. I have no problem retrieving, I just need to parse it in to two strings. The string has 4 variations.
Here are examples: 3"x4" 3"hx4"w 3hx4w 3x4
The width is always the first number and the height is always the second. Sometimes, the width and height have decimal points. Any way to parse this into two strings of the numeric values only?
I have written code to pull some data into a data table and do some data re-formatting. I need some help splitting some text into appropriate columns.
CASE 1
I have data formated like this that I need to split into 2 columns.
[Code]...
column is the first 11 characters That is easy.column 2 should contain all the text after the first 11 characters up to but not including the first number.The last column is all the text after column 2
What I'm trying to do is parse out some links via a google search and fill a text box with said results. This is the code I have in a module which I call upon inside of a command button.
I have a parse from Wikipedia saved in a text file in the following form: The town itself is situated to the south-east of the rock, and overlooks the Palaia Monemvasia bay. A small hamlet with about 10 houses lies to the northwest.The founding of the town and fortress of Monemvassia most probably occurred in the 6th century AD. The town was founded in 583 by people seeking refuge from the [[Slavic peoples|Slavic]] and the [[Eurasian Avars|Avaric]] invasion of Greece. From the 10th century AD, the town developed into an important trade and maritime centre. The fortress withstood the [[Arab]] and [[Normans|Norman]] invasions and conquests in 1147. Cornfields that fed up to 30 men were grown inside the fortress.What I need to do is to extract specific texts from the parse given the header names. For example, if I type in a textbot Geography I need ONLY the geography text returned.
I want regular expression validator for my telephone field in VB.net. Telephone format should be (+)xx-(0)xxxx-xxxxxx ext xxxx (Optional) example my number would appear as 44-7966-591739 Screen would be formatted to show +44-(0)7966-591739 ext?
I have an application that downloads a .txt file via FTP, and then it calls some sql to insert the file data into my database. I want to check whether the file is in the correct format before trying to insert.
The file should consist of some number of rows, each with the following format:
(4 letter code) (tab) (3 or 4 letter code) (tab) (date as dd-MMM-yy) (tab) (variable length text description) (tab) (1 letter code)
Is there a good way to check whether every line in the file follows this pattern, and warn me if it doesn't?
Regex in VB2008.I have a file system directory that my code is watching. When a file is placed in that directory my code kicks off a processing application. Based on the filename structure, the code will perform different processes. So I need to match the filename structure specficially to get the correct processes to run on that file.My file name structure is: IK2YYYYMMDD_VV.e;where YYYYMMDD is well, the year, month and day. And VV is a verison number from 00-99 If the new file saved in the directory match this structure then I want a TRUE returned. From a filewatcher I get the filename as an "e.Name" (FileSystemEventArgs) variable. My current code to see if it matches the baseline structure is;
Dim IKPred2Match as New Regex ("^IK2.*\.e$") Dim ValidIKPred2Match as MatchCollection = IKPred2Match.Matches(e.Name)I've tried many different regex match patterns, and just can't seem to find the magic one.
I'm trying to type a regular expression that follows the following format: [URL] There are no special characters or numbers permitted for this criteria. I thought I had it down, but I'm a bit rusty with regular expressions and when I tested mine, it failed all across the boards. So far, my regular is expression is:
I am trying to parse the parameters of Excel formulas like "=a(b)", "=a(b,c)", "=a(b,c,d)". I'd like extract the function name "a" and the parameters "b", "c" and "d".
There are loads of examples on SO to parse HTML and so forth, but none specifically for parentheses.
So far, I've got this "=(.+)(([^,)]*)(,[^,)]*)*)" but when I parse "=a(b,c,d)" it puts "a" in match(1), "b" in match(2) and ",d" in match(3). So "c" is lost and the comma before the "d" is a pain.
How can I parse a string like this with an arbitrary number of parameters, ideally dropping the commas?
The ability to parse "=a(b(c),d(e(f)))" would be great...
Edit: I know that a parser is the correct solution and I have used Devin Cook's excellent Gold Parser with great results before.
However, the particular case I'm facing is to extract the arguments from a known Excel formula. Specifically, if the formula contains the string "=Travel(", I know that it will have 4 arguments and if they don't parse it's not a problem. This is simply a "nice to have" function which can fail occasionally without it being an issue.
regex for "=a(b,c,d)", "=a(b,c,d,e)", etc., with the constraint that there will be no nested parentheses or commas?
I am been stuck on this for 3 days now...I have been accessing the twitter api to pull a user_timeline for a list of users and the json that comes back is impossible to work with. I tried to deserialize it using javascriptserializer and get an error:invalid object passed in , ':' or '}'
Now this is frustrating since I expect the json being returned to be error free. Then I tried json.net and split the posts using string.split and tried to convert each post to Jobject or jarray. for Jarray I get
'unexpected end of content while loading jArray
[Code]...
Now I have formatted the code here and not pasted the whole file but it does look like valid json to me and I do not alter anything after receiving the stream from the twitter api. Can someone please point me in the right direction? I really need to get this stuff parsed?