parsing

Parse string to get an array of the URLs

Hi, Imagine I have a string - something like this: This is some really cool text about http://google.com/ and it also contains some urls like http://apple.com/ and its very nice! This is too long and I need to do some magic stuff to fix this very big problem. Oh no. As you can see there are two URLs in the string and somehow, assumin...

Poker hand range parser ... how do I write the grammar?

Hi all - I'd like to build a poker hand-range parser, whereby I can provider a string such as the following (assume a standard 52-card deck, ranks 2-A, s = suited, o = offsuit): "22+,A2s+,AKo-ATo,7d6d" The parser should be able to produce the following combinations: 6 combinations for each of 22, 33, 44, 55, 66, 77, 88, 99, TT, JJ, ...

Parsing an "advanced" INI file with PHP

Basically, I would like a simple, easy, one-file way to parse an INI file with "advanced" features, like section inheritance and property nesting, like Zend_Config_Ini. For example: [foo] a = 1 b.a = 2 b.b = 3 b.c = 4 c = 5 [bar : foo] b.b = 17 c = 42 Would parse into array( 'foo'=>array( 'a'=>'1', 'b'=>array( 'a'=>...

Resources on parsing expressions

I'm writing a program that needs to build syntax trees from expressions in prefix notation. What resources would you recommend I look into to learn about parsing expressions? ...

Reading CGI POST data the most efficient way

I'm in great need of a way to dig through potentially huge amounts of CGI supplied POST data. With reading the GET data it's no big deal, as I can just re-request the QUERY_STRING environment variable as often as I want, but with POST data which is supplied via stdin. I can only read it in once and have to store it somewhere. My curre...

Read structured data from binary file - ?

I know the file structure, suppose this structure is this: [3-bytes long int],[1-byte long unsigned integer],[4-bytes long unsigned integer] So the file contains chains of such records. What is the most elegent way to parse such a file in Java? Supposedly, we can define a byte[] array of overall length and read it with InputStream, ...

outlook PST File extracting via libpst + python

Hello , had anyone successfully import and used libpst via python, to extract outlook PST files : http://www.five-ten-sg.com/libpst/ from source package? It have python bindings but i cannot import after installing (even test.py script comes with it dont work) Here is Mercurial repo to latest version. Can you guys give a try? i need he...

No more BeautifulSoup

Hi there.. I have been using BeautifulSoup but as I understand it that library is no longer being maintained. So what should I use ? I have heard about Xpath but what else is there ? ...

Parsing .c/.cpp/.py source files in Python to get a list of the functions contained

I'm trying to learn about parsers, for Python, C and C++ source (on my own, not for a school project). Here is a summary of what i want to do: 1) read .c/.cpp/.py source files in Python 2) get a list of all the functions in the source files, and the span of their definitions in terms of line numbers. So to illustrate my question, con...

Parsing date from Calendar in Java

Hi, I am having following function public static Date parseDate(String date, String format) throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat(format); return formatter.parse(date); } I am using this as follows in my code Calendar eDate = Calendar.getInstance(); eDate.add(Calendar.DAY_OF_MON...

How is a NullLiteral represented in tree form?

According to the ECMAScript specification in section 7.8.1 a NullLiteral is defined as follows: NullLiteral :: null What I am trying to understand is how this is represented in tree form when a NullLiteral is included in the following productions found in sections 7.6.1 and 7.8. ReservedWord :: Keyword FutureReserved...

Parse log files programmatically in .NET

We have a large number (read: 50,000) of relatively small (read under 500K, typically under 50K) log files created using log4net from our client application. A typical log looks like: Start Painless log Framework:8.1.7.0 Application:8.1.7.0 2010-05-05 19:26:07,678 [Login ] INFO Application.App.OnShowLoginMessage(194) - Validating Crede...

Java XML parser without excessive memory allocation

At work I am parsing large XML files using the DefaultHandler class. Doing that, I noticed that this interface allocates many Strings, for element names, attribute names and values, and so on. From that, I thought about creating an XML parser that only does the absolute minimum of object allocation. Currently I need: one StringBuilder...

What's the best performing xml parsing for GAE (Python Version)?

I think we all know this page, but the benchmarks provided dated from more than two years ago. So, I would like to know if you could point out the best xml parser around. As I need just a xml parser, the more important thing to me is speed over everything else. My objective is to process some xml feeds (about 25k) that are 4kb in size (t...

Perl web scraper, extract content from DIV that only has "style" tag?

I'm stuck on this and have been all day.. I'm still pretty new to parsing / scraping in perl but I thought I had it down until this.. I have been trying this with different perl modules (tokeparser, tokeparser:simple, web parser and some others)... I have the following string (which in reality is actually an entire HTML page, but this is...

Parse weird formatted data to XML?

Okay sample output data is below, it looks something like JSON, but it's not formatted exactly like JSON. So I am wondering, how can I get this data looking like XML, preferably with php? Thanks! [{ action:'getallregions', reply:[{regionid:'1',name:'Blue',description:'Research Route',color:'508CEB',active:'true',parentRegionId:'0',paren...

How to parse back the result of string.Format

Let's say I have a number (e.g. double) and transform it using some format string into a string variable : var str = string.Format("{0:0%}", 0.256); (the content of the str variable is in this case "26%"). Is there any way to parse this string back into the number ? I'm aware that depending on the format string the lossless conversi...

Parsing text files using Python

I am very new to Python and am looking to use it to parse a text file. The file has between 250-300 lines of the following format: ---- Mark Grey ([email protected]) changed status from Busy to Available @ 14/07/2010 16:32:36 ---- ---- Silvia Pablo ([email protected]) became Available @ 14/07/2010 16:32:39 ---- I need to store the f...

String to Date Parsing not working

I am getting date as string as a parameter from Servlet. Now when I am trying to parse it again to get util.Date, it gives me error. I am getting string "Fri Jul 02 00:00:00 IST 2010" & I want util.Date from it. Tried SimpleDateFormat, DateFormat but didn't work. ...

Use and parse a text file in C# to initialize a component based game model

I have a text file that should initialize my objects, which are built around a component based model, it is my first time trying to use a data driven approach and i'm not sure if i am heading in the right direction here. The file i have currently in mind looks like this EliteGoblin.txt @Goblin.txt [general] hp += 20 strength = 12 de...