parsing

How to convert foreign string representations of number with decimals into doubles?

I am at an internship where there is parsing done on strings read from a XML file. Specifically the strings are representations of decimal numbers. A problem arises when I try to parse a decimal string formatted differently than the ones that have comma separators and a decimal point. For example the way that nations format their decimal...

how to keep count of replaced strings

I have a massive string im trying to parse as series of tokens in string form, and i found a problem: because many of the strings are alike, sometimes doing string.replace()will cause previously replaced characters to be replaced again. say i have the string being replaced is 'goto' and it gets replaced by '41' (hex) and gets converted ...

Implementing parser for markdown-like language

I have markup language which is similar to markdown and the one used by SO. Legacy parser was based on regexes and was complete nightmare to maintain, so I've come up with my own solution based on EBNF grammar and implemented via mxTextTools/SimpleParse. However, there are issues with some tokens which may include each other, and I don...

Can I look at the actual line that was the source of an element parsed from an html document using lxml

I have been having fun manipulating html with lxml. Now I want to do some manipulation of the actual file, after finding a particular element that meets my needs I want to know if it is possible to retrieve the source of the element. I jumped up and down in my chair after seeing sourceline as a method of my element but that did not giv...

How to parse an HTML page using PHP?

Parsing HTML / JS codes to get info using PHP. www.asos.com/Asos/Little-Asos-Union-Jack-T-Shirt/Prod/pgeproduct.aspx?iid=1273626 Take a look at this page, it's a clothes shop for kids. This is one of their items and I want to point out the size section. What we need to do here is to get all the sizes for this item and check whether the...

Preferred way to parse a custom binary flat file?

I have a flat file generated by a C program. Each record in the file consists of a fixed length header followed by data. The header contains a field indicating the size of the following data. My ultimate goal is to write a C#/.NET program to query this flat file, so I'm looking for the most efficient way to read the file using C#. ...

Any one have an example that uses the element.sourceline method from lxml.html

I hope I asked that correctly. I am trying to figure out what element.sourceline does and if there is some way I can use its features. I have tried building my elements from the html a number of ways but every time I iterate through my elements and ask for sourceline I always get None. When I tried to use the built-in help I done't ge...

Implementing a simple XML based Scripting Language for an XNA Game

Hello, I'm working with a team on a RPG engine in C# and XNA. We're planning on targeting Windows and Windows Phone 7, but are running into issues with AI interactions and controlling player actions during cutscenes. FOr the most part, everything is extracted using the MVC design pattern, but abstracting all logic and movement into a con...

Attempt to parse JSON without crashing Node.js server.

Hey, I'm developing a project using Node.js at the backed, with that I'm also using JSON to pass data to and from clients over web sockets. The problem I have is that if an invalid string was sent to the server (easily done by the user messing with the JavaScript console) then it would crash the server while trying to parse it. The cur...

I do not want to parse some tags in XML

Currently this would be a sample XML that I am working on: <smsq> <sms> <id>96</id> <to>03333560511</to> <msg> danial says: hahaha <space> nothing. </msg> </sms> </smsq> Now please notice, that the tag can contain other tags (which should not be parsed) and I had to make a dtd for that. The dtd was something like this: ...

Java: how to check that a string is parsable to a double?

Is there a native way (preferably without implementing your own method) to check that a string is parsable with Double.parseDouble()? ...

Is it possible to tell whether or not some javascript code call particular function?

I am trying to build some sort of a javascript "antivirus" that would try to catch particular function calls. So lets say I've got some random javascript file, can I check if it doesn't use function jQuery.trim() (just for example sake) anywhere? It seems like pretty complicated task, plus there are eval and base encodings which could...

What's the easiest way to remove all attributes from a XML in C#?

Hi, I want to remove the attributes of all tags from a XML (I want to keep only the tags and their inner value). What's the easiest way to do this in C#? ...

Converting a number to a string and back

I have always used streams, printf, string(x) or whatever the language in question offered to convert numeric types to a string or back. However I have never really considered how this is actually done. I searched around on Google, but all the results are just to use those varies methods, and not how the conversion is really done behind ...

Printing and concatenation with Parse::RecDescent

I am testing the grammar from P::RD tutorial in order to develop my own grammar. I haven't figured out how to print a string declaration and append '$' to the front of it. For example "STRING sDir" should print out "$sDir". It is simple enough to just do a $string =~ s/STRING /\$/, but what about the case where there is assignment? eg. "...

want to write MS-Access like query builder in c?#

Hi we want to create MS-Access LIKE query parser where user can create complex queries having joins? any thoughts on design in c#? ...

How to extract the first word that follows a string?

For example, say I have a text file example.txt that reads: I like dogs. My favorite dog is George because he is my dog. George is a nice dog. Now how do I extract "George" given that it is the first word that follows "My favorite dog is"? What if there as more than one space, e.g. My favorite dog is George ..... Is there a wa...

What is the fastest way to parse text?

Say I want to extract the first word (or floating point number) that follows a given string found in some text file (see http://stackoverflow.com/questions/3549877/how-to-extract-the-first-word-that-follows-a-string). I know you can do it with perl, or sed, and probably many other ways. I am looking for performance. What is the fastest w...

Parse Simple DateTime

DateTime dt = DateTime.ParseExact("1122010", "Mddyyyy", System.Globalization.CultureInfo.CurrentCulture); Throwing this exception: String was not recognized as a valid DateTime. I'm sure it's the lack of a leading 0 in the month. What's the correct format string? ...

Python parser script layout

Hi everyone! I'm writing a simple Python parser, where I loop over each line in a file, and prosess it further if the right conditions are met. My short start: def identify(hh_line): if(re.match(regex.new_round, hh_line)): m = re.match(regex.new_round, hh_line) # insert into psql ... ...