parsing

reading a json object in jsp

i have a JSON object passed to the jsp page. it is passed as a string. now i have to parse this string and retrieve the values that are passed through the JSON object. so that i can print the values in the same jsp. ...

While processing an email reply how can I ignore any email client specifics & the history?

I have a rails application which processes incoming emails via IMAP. Currently a method is used that searches the parts of a TMail object for a given content_type: def self.search_parts_for_content_type(parts, content_type = 'text/html') parts.each do |part| if part.content_type == content_type return part.body e...

YAML parser in Delphi?

Are there any YAML parsers or YAML Serialization libs in Delphi? ...

RSS/Atom parsing library for .Net

Hi, I'm trying to find a library that can read a given RSS/Atom feed, and that can guess its format and abstract it as a list of items. The idea is to build a simple RSS reader that could take any feed. I know PHP has a few libraries doing just that, but I can't find any .Net version. ...

HTML Parsing - Get Innermost HTML Tags

When I parse HTML I wish to obtain only the innermost tags for the entire document. My intention is to semantically parse data from the HTML doc. So if I have some html like this <html> <table> <tr><td>X</td></tr> <tr><td>Y</td></tr> </table> </html> I want <td>X</td> and <td>Y</td> alone. Is this poss...

What's the best way to extract Excel cell comments using Perl or Ruby?

I've been parsing Excel documents in Perl successfully with Spreadhsheet::ParseExcel (as recommended in http://stackoverflow.com/questions/429193), but I can't figure out how to extract cell comments. Any ideas? A solution in Perl or Ruby would be ideal. ...

Logic expression parser

I'm trying to create a logic expression parser for expressions like: ((VariableA -> VariableB) AND NOT VariableC) The parser should be able to return, wheather the result is true or false for given values of variables. Basicly the expressions will only contain variables, logical operators (or, and, implication, equivalence, negation a...

Using a parser generator such as BISON, while still handling bad input gracefully

I need a parser for a language that isn't all that complicated. The only catch is, I never want the parser to raise an error when it receives malformed input. Rather, I want it to just continue, making as much sense of the input as it can, similar to what the HTML parsers in a web browser do. I naturally thought to use a parser generato...

How can I use bash (grep/sed/etc) to grab a section of a logfile between 2 timestamps?

I have a set of mail logs: mail.log mail.log.0 mail.log.1.gz mail.log.2.gz each of these files contain chronologically sorted lines that begin with timestamps like: May 3 13:21:12 ... How can I easily grab every log entry after a certain date/time and before another date/time using bash (and related command line tools) without compar...

processing json objects in jsp

i have a JSON object sent from the browser to the jsp page. how do i receive that object and process it in jsp. do i need any specific parsers? i have used the following piece of code. but it wouldnt work. essentially i should read the contents of the object and print them in the jsp. <%@page language="java" import="jso.JSONObject"%> ...

Haskell: Writing text files and parsing them back to original format

Hi - I have a list of tuples of format [(String,String)] and I need a function to write the contents of the list to a text file, then another function to read this text file in as the same list of tuples. Here's what I've got for the saving function: save :: Table -> IO() save [] = writeFile "database.txt" "" save zs = do { writeFile "d...

Parsing a string in C++

Hi, I'm trying to make a constructor for a graph class that accepts a string as a parameter and uses it to build the graph. The string is formatted as follows: |vertex list|Edges list| e.g. |1,2,3,4,15|(1->2),(3->2),(4->15)| The idea is that the constructor will take the values from the string and then know to perform the following a...

C# Decimal.Parse issue with commas

Here's my problem (for en-US): Decimal.Parse("1,2,3,4") returns 1234, instead of throwing an InvalidFormatException. Most Windows applications (Excel en-US) do not drop the thousand separators and do not consider that value a decimal number. The same issue happens for other languages (although with different characters). Are there any...

Best modern text parsing? AKA When to use Lex and Yacc?

I have as input blocks of text with commands and arguments, one per line, such as XYZ ARG1,ARG2,ARG3,...,ARGN And I want to verify that the arguments to XYZ are well formed for that particular command and execute the correct block of code if they are. There are something like ~100 commands, some of which have variable numbers of argum...

How can I parse dynamic SQL before execution in T-SQL?

I'd need to know how to parse a query to know if it is well build before executing it. If the parsing is correct then execute it, if not discard it. I haven't been able to accomplish this using SET NOEXEC, SET PARSEONLY, TRY/CATCH. I m using dynamic sql inside a loop. Sometimes the dynamic sql is incorrect not for my fault but for the ...

Is there an implementation of "getopt" for Delphi?

It doesn't get much easier than using getopt() to parse command line parameters in C/C++. Is there anything similar for Delphi? Or ideally, with the same syntax? I know Delphi supports FindCmdLineSwitch and ParamStr(), but those still require some additional parsing. I want something that works like getopt() in C. Something that easily...

PHP XML Parser - ignoring nested/child tags

I've got a situation where I'm using an XML parser to extract data from a php://input. The data being sent in looks like:- <this>foo</this> <that>bar></that> <data><dong>zebras</dong><fong>monkeys</fong></data> Now, the issue is that because the handler:- $xml_parser = xml_parser_create(); xml_parser_set_option($xml_parser...

JavaCC - Parse math expressions into a class structure

I'm using this grammar to calculate math expressions: // Konfiguration (JavaCC-Manual konsultieren) options { STATIC = true; // alle Parser-operationen sind static // verwende zwei Token um zu entscheiden, was passieren soll LOOKAHEAD = 2; } // hier beginnt unsere Parser Klasse ("MathParse") PARSER_BEGIN(MathParse) // h...

Extracting a URL in Python

In regards to: http://stackoverflow.com/questions/720113/find-hyperlinks-in-text-using-python-twitter-related How can I extract just the url so I can put it into a list/array? Edit Let me clarify, I don't want to parse the URL into pieces. I want to extract the URL from the text of the string to put it into an array. Thanks! ...

HTML Parser

Anyone know of an HTML parser for VB.NET or C#? I know .NET has a lot of XML support, like XMLReader and XMLWriter. Is there an HTMLWriter or HTMLReader? Ultimately what I'd like is a library that will parser an HTML file and raise events based on the tags it finds. Anyone know of a library to do this? ...