parsing

Need some advice/suggestions on template syntax.

Heya! I've coded a small php template parser, so templates can be easily parsed, and the variables within the templates are like {variable_name} e.g. <title>{title}</title> Can you suggest me possible if/else statement syntax? I've thought of doing something like: {if {logged_in}: TRUE} You're logged in... {else} You're not... {/if...

How to match optional open/close tags in JavaCC?

What JavaCC syntax does implement grammar that can parse these kind of lines: [b]content[/b] content[/b] [b]content Although the JavaCC parser needs to parse all lines, it must distinguish correct and incorrect tagging behavior. Correct tags are like the 1st line, they have an open and close tag. When the tags are matched this will o...

How Parsing string between [STX] and [ETX] using C# - Split/Append output using Regex or String Functions

Language = C#.NET Anything that is between [STX] and [ETX] must be accepted rest of the things must be rejected. string startparam = "[STX]"; string endparam = "[ETX]"; String str1 = "[STX]some string 1[ETX]"; //Option 1 String str2 = "sajksajsk [STX]some string 2 [ETX] saksla"; //Option 2 String str3 = "[ETX] dksldkls [STX]some stri...

Run `head` on a text file inside a zipped archive without unpacking the archive

Greetings, I've taken over from a prior team and writing ETL jobs which process csv files. I use a combination of shell scripts and perl on ubuntu. The csv files are huge; they arrive as zipped archives. Unzipped, many are more than 30Gb - yes, that's a G Legacy process is a batch job running on cron that unzips each file entirely, rea...

Dynamically replace the “src” attributes of all <img> tags (redux)

Possible Duplicate: Dynamically replace the src attributes of all <img> tags Funny story: I posted this very question a short time ago, but instead of getting something I could, you know, use, all I got was a lot of dogma about the evils of using regex to parse HTML. So here goes again. I have some HTML and want to replace th...

How do I determine if there are two or one numbers at the start of my string?

I need a function or some code so I can find out what the number at the start is; Basically need to know the number at the start; The number can be 1 or 2 digits long 35|http:\/\/v10.lscache3.c.youtube.com\/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0dXSlZRTl9FSkNNN19OS1JJ&fexp...

How do I remove a portion of my string?

Continuing from my previous question, I now want to remove the number once I have found it and stored it in a variable. ...

How Can I Parse a Document and Replace the Content to Change Context from 1st or 2nd Person to 3rd Person?

Basically I need some text like: I have an ice cream cone. You are in trouble. You need a bath. And change it from 1st or 2nd person to 3rd person. He has an ice cream cone. He is in trouble. He needs a bath. I've started a js app, but it's super simple at the moment. Before I waste time reinventing the wheel, I figured I'd ask:...

How to find dates in the sentence using NLP, RegEx in Python

Hi Can anyone suggest me some way of finding and parsing dates (in any format, "Aug06", "Aug2006", "August 2 2008", "19th August 2006", "08-06", "01-08-06") in the python. I came across this question, but it is in perl... http://stackoverflow.com/questions/3445358/extract-inconsistently-formatted-date-from-string-date-parsing-nlp Any ...

Improve BNF for mathematic expressions

A good exercise while learning programming, is to write a calculator. To do this, I created some kind of DSL in BNF and want to ask for your help to improve it. With this minilanguage you should be able to add, multiply and assign values and expressions to names (a.k.a. create variables and functions). Hava a look at the BNF first: <Pr...

how to create parser for TEX?

I am looking to develop a TEX parser, now problem is there is no Context Free Grammar and there can not be one, because its not context free language, I heard that it is some sort of macro language and that builds on its own. So now I need direction of what kind of grammar this macro language has and how to build anything upon in c#. I...

difference between predictive & recursive descent parser grammar

A recursive descent parser is a top-down parser built from a set of mutually-recursive procedures (or a non-recursive equivalent). I want to know that is the predictive parser and recursive descent parser are one and the same.Please explain with reasons. Explain the following grammar rules of recursive descent parser : E ::= T{+T}* T ...

PHP Simple HTML DOM Parser

Hi Guys, How come you can't use the Class's traversing methods with variable's to set the parameters For instance Using this array: array(0 => array('element' => 'img[src=images/more.gif]', 'attribute' => 'parent()->href')); this works: foreach($this->contents->find($target[$key]['element']) as $keyz => $found) { $this->store[$ke...

Groovy String to Date

I am coding this with Groovy I am currently trying to convert a string that I have to a date without having to do anything too tedious. String theDate = "28/09/2010 16:02:43"; def newdate = new Date().parse("d/M/yyyy H:m:s", theDate) Output: Tue Aug 10 16:02:43 PST 2010 The above code works just fine, however when my string cha...

By grammar rules of recursive descent parser how can we validate the source string.

If the following two input strings are inputed : 1)<id> + <id> * <id> 2) <id> * <id> <id> E ::= T{+T}* T ::= V{*V}* V ::= <id> Then by applying the above grammar rules of recursive descent parser how can we validate the above source string. What type of the error will be indicated by recursive descent parser ? Thanks... ...

FIRST and FOLLOW sets What are they used for in parsing?

What are FIRST and FOLLOW sets?What are they used for in parsing? Are they used for top-down or bottom-up parsers ? Can anyone explain me FIRST and FOLLOW SETS for the following set of grammar rules: > E := E+T | T > > T := T*V | T > > V := <id> ...

C# Html Agility Pack ( SelectSingleNode )

I'm trying to parse this field, but can't get it to work. Current attempt: var name = doc.DocumentNode.SelectSingleNode("//*[@id='my_name']").InnerHtml; <h1 class="bla" id="my_name">namehere</h1> Error: Object reference not set to an instance of an object. Appreciate any help. @John - I can assure that the HTML is correctly loaded...

Get post data from page

I've faced with problem i need to get content from site but before i need authorize. Now i looking for library(or some kind of this stuff) to parse all post data (i try use regex but i searching for alternative) ...

Json Parsing in Android Application

Hi Team, After completing the XML SAX Parsing now I am working on JSON Parsing in my application. Here I am providing you the Json Response : {"menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, ...

Parse SQL file to separate columns

Hi, I have a sql file which has a lot of insert statements (over 3000+). E.g. insert into `pubs_for_client` (`ID`, `num`, `pub_name`, `pub_address`, `publ_tele`, `publ_fax`, `pub_email`, `publ_website`, `pub_vat`, `publ_last_year`, `titles_on_backlist`, `Personnel`) values('7','5','4TH xxxx xxxx','xxxx xxxx, 16 xxxxx xxxxx, xxxxxxx, W...