parsing

Question about parsing HTML using Regex and Java

I Have a question about finding html tags using Java and Regex. I am using the code below to find all the tags in HTML, documentURL is obviously the HTML content. The find method return true, meaning that it can find something in the HTML but the matches() method always return false and I am completly and utterly puzzled about this. I...

How to parse HTTP responses in C?

Hi, I'm writing a little project which interacts with a set of servers using HTTP 1.1 GET and POST. The server gives me the response after some header lines, so I though on using strtok() function using \n as the delimiter but there is a crash whenever I try to do so. Is there any simple way to parse a HTTP response in C? I would like n...

how to load data and store the data from a file using numpy

I have the following file like this: 2 qid:1 1:0.32 2:0.50 3:0.78 4:0.02 10:0.90 5 qid:2 2:0.22 5:0.34 6:0.87 10:0.56 12:0.32 19:0.24 20:0.55 ... he structure is follwoing like that: output={} rel=2 qid=1 features={} # the feature list "1:0.32 2:0.50 3:0.78 4:0.02 10:0.90" output.append([rel,qid,features]) ... How can I write my ...

Regex for random text replacement on input stream

I have a paragraph of text below that I want to use an input source. And I want the doSpin() function to take the stream of text and pick one value at random, from each [%group of replacement candidates%]. This [%should|ought|would|could%] make it much [%more convenient|faster|easier%] and help reduce duplicate content. So th...

Parse error on explode('-','foo-bar')[0] (for instance)

Why doesn't php support this syntax: $s = explode('-', 'foo-bar')[0]; ? ...

Converting xml attribute to array

In the following XML: <myxml> <photos> <photo url="1.jpg"/> <photo url="2.jpg"/> <photo url="3.jpg"/> <photo url="4.jpg"/> </photos> </myxml> How do I use e4x to extract the urls and push them in an array with the least possible code? ...

Show image with link based on first directory with Javascript

Hi, i need some help please, i want to show an image on my Page depending of the first directory of the URL. Example: In Any of this URLs will show the image1.jpg www.mysite.com/audio/amplifiers/400wats.html www.mysite.com/audio/ www.mysite.com/audio/amplifiers/ In any of this others will show the image2.jpg www.mysite.com/video...

Query XML file with PHP to return certain bookmarks...

I have an XML file full of bookmarks from Google Bookmarks. (File: http://gist.github.com/324844) I want to pull the bookmark based on this path: xml_api_reply->bookmarks-bookmark->labels->label. So, my question is How can I use SimpleXML to grab the bookmarks that have the label Inspiration? Some bookmarks may have more than one bookm...

Insert unicode strings into CleverCSS

How can one insert a Unicode string CSS into CleverCSS? In particular, how could one produce the following CSS using CleverCSS: li:after { content: "\00BB \0020"; } I've figured out CleverCSS's parsing rules, but suffice that the permutations I've thought sensible have failed, for example: li: content: "\\00BB \\0020" // beco...

XpathQuery to retrive particular data from html page in iphone.

I am new to iphone development.I want to retrieve a particular data from a HTML page (Data inside a particular tag like This is title).I have the link of the web page.How should i use xpathQuery to retrieve "This is title" inside the tags.Please help me out.Thanks. ...

If you're not supposed to use Regular Expressions to parse HTML, then how are HTML parsers written?

I see questions every day asking how to parse or extract something from some HTML string and the first answer/comment is always "Don't use RegEx to parse HTML, lest you feel the wrath!" (that last part is sometimes omitted). This is rather confusing for me, I always thought that in general, the best way to parse any complicated string i...

Can someone explain how JSON parsers work without using eval at all?

I can't comprehend how it works without using eval - what's the secret behind this? Edit: Could someone present a trivial example of how the tree structure is converted to an object? ...

How can I use Convert.ChangeType to convert string into numerics with group separator?

Hello, I want to make a generic string to numeric converter, and provide it as a string extension, so I wrote the following code: public static bool TryParse<T>( this string text, out T result, IFormatProvider formatProvider ) where T : struct try { result = (T)Convert.ChangeType( text, typeof( T ), formatProvider ); return true;...

Coding a parser for a domain specific language in Java

We want to design a simple domain specific language for writing test scripts to automatically test a XML-based interface of one of our applications. A sample test would be: Get an input XML file from network shared folder or subversion repository Import the XML file using the interface Check if the import result message was successfull...

System.Uri can't parse when password field contains a "#"

The following code throws System.UriFormatException: var uri = new UriBuilder("ftp://user:pass#[email protected]:21/fu/bar.zip"); System.UriFormatException: Invalid URI: A port was expected because of there is a colon (':') present but the port could not be parsed. Removing the # symbol from the password field solves the issue. ...

Treetop basic parsing and regular expression usage

I'm developing a script using the ruby Treetop library and having issues working with its syntax for regex's. First off, many regular expressions that work in other settings dont work the same in treetop. This is my grammar: (myline.treetop) grammar MyLine rule line string whitespace condition end rule string ...

Perl XML::Simple XMLout function

I pass in the following XML to XMLin: <root foo="bar" foo2="bar2"> <pizzas> <pizza>Pepperoni</pizza> </pizzas> </root> I then edit part of the root element via hash array. I don't care about the pizza, but I do need that XML to come back out exactly as it was. However, I get the following from XMLout: <root foo="bar" foo2="bar2"> <...

Delphi: Transporting Objects to remote computers

Hallo. I am writing a tier2 ordering software for network usage. So we have client and server. On the client I create Objects of TBest in which the Product ID, the amount and the user who orders it are saved. (So this is a item of an Order). An order can have multiple items and those are saved in an array to later send the created ord...

Looking for a tutorial on Recursive Descent Parsing.

I am trying to parse some data to no success. Can anyone recommend a good introduction with a lot of examples to Recursive Descent Parsing? I haven't been able to find any. ...

XAML Parsing Exception

I have a simple XAML page that load fine when it is loaded as part of any application within Visual Studio. However, when I deploy this application using ClickOnce, I get the following exception: Type : System.Windows.Markup.XamlParseException, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 ...