Click here to Skip to main content
15,895,782 members
Everything / Parsing

Parsing

parsing

Great Reads

by honey the codewitch
Creating a simple parser in 3 easy lessons
by honey the codewitch
An LL(1) pull parser and generator that thinks it's an LL(k) parser - with a rich, simple and beautiful EBNF syntax
by User 6679439
Comprehensive unit parsing library
by honey the codewitch
Easily implement efficient backtracking capabilities over any enumeration

Latest Articles

by CaldasGSM
The article discusses the implementation of a zero allocation JSON parser in C, which is suitable for systems with limited memory resources.
by honey the codewitch
Stream JSON efficiently on little devices with minimal flash and memory usage
by Christopher Diggins
An introduction to building recursive descent parsers in C# using the Parakeet parsing library
by Member 10522374
This library was created to parse the AutoCad Dxf format.

All Articles

Sort by Score

Parsing 

14 Nov 2019 by honey the codewitch
Creating a simple parser in 3 easy lessons
14 May 2019 by honey the codewitch
An LL(1) pull parser and generator that thinks it's an LL(k) parser - with a rich, simple and beautiful EBNF syntax
1 Jun 2018 by User 6679439
23 Dec 2019 by honey the codewitch
Easily implement efficient backtracking capabilities over any enumeration
2 Jan 2021 by honey the codewitch
Hoodwink your computer into doing your work for you using regular expressions
6 Apr 2012 by Matthew So (Hong Kong)
Use the GOLD Parser to define a language for mapping between two business entities, create a parser using the bsn-goldparser engine, and generate an assembly using CodeDom.
31 Jul 2012 by Shuqian Ying
The source code and a simple demo program for a plug-in in Microsoft Managed Extensibility Framework (MEF) that provides visual display of email messages.
18 Feb 2020 by honey the codewitch
A crash course in GLR parsing which can be used to parse highly ambiguous grammars
5 Jan 2017 by epicTurk
Parse quser.exe Results in Regex in any .NET language
14 Jul 2019 by honey the codewitch
Creating a simple parser in 3 easy lessons
11 Dec 2019 by honey the codewitch
If you use the CodeDOM, here's an indispensable package to make it awesome.
19 Mar 2024 by Christopher Diggins
An introduction to building recursive descent parsers in C# using the Parakeet parsing library
21 Nov 2015 by Matt Scarpino
This article explains how to generate a high-performance text scanner using re2c.
14 Jul 2019 by honey the codewitch
Creating a simple parser in 3 easy lessons
2 Dec 2017 by User 6679439
Library extending the .NET numeric support
11 Jun 2012 by Maciej Los
Have a look at this: DateTime.TryParse[^] method and use it.DateTime.TryParse Method (String, IFormatProvider, DateTimeStyles, DateTime%)The most important is:Specific valid formats for date and time elements, as well as the names and symbols used in dates and times, are defined by the...
19 Jun 2012 by paladin_t
A simple plist parser within 100 lines of C# code.
2 Apr 2013 by Sergey Alexandrovich Kryukov
The whole idea is wrong: the type double as any other numeric type, do not have "exponential form". The "exponential form" is only applicable to a string representing numbers, not the numbers themselves.If you want to know how floating-point numbers are represented, please see: learn the...
10 Sep 2013 by Sergey Alexandrovich Kryukov
What you describe is not "Window raw data", this is disk raw data. It has nothing to do with Windows or Linux and has the same structure for both. There is nothing to "parse".And let me tell you that you are not saving any files. You are saving raw data which you can utilize if you have the...
6 May 2015 by User 11633146
Parsing is where the story of compilation begins.
13 Aug 2015 by CPallini
As an alternative, you may embed a script language, like Lua in your application and then let the script engine evaluate expressions (and more complex constructs) for you. We have an article on this very topic: "Integrating Lua into C++" here at Code Project[^].See also "Evaluating...
25 Jul 2019 by honey the codewitch
A parser generator and tool for exploring LL parsing algorithms
20 Aug 2019 by honey the codewitch
Using PCK to create grammars, parsers and tokenizers for C# and other .NET languages
22 Feb 2020 by honey the codewitch
Glory can parse virtually anything, even natural language. Add powerful parsers to your projects. Parse languages like C# or incorporate human language parsing with your AI code.
11 Dec 2020 by honey the codewitch
Streaming your data and parsing on the go with tiny gadgets
29 Dec 2020 by Miriam Weiss
Hi!Now, I know what you're thinking ("Not another parser error!"). But my situation is unique. (No, really! ;-) ) I could use your help. Let me tell you what the error is:Server Error in '/'...
7 Sep 2012 by Espen Harlinn
Apart from what Sergey mentions, you could look at the Solution2 interface[^] and the Project interface[^]Controlling Projects and Solutions[^]It's a lot of info to wade through, but what you're looking for is there somewhere.Best regardsEspen Harlinn
16 Nov 2012 by Maciej Los
It's simple. Start here: SQL Parser[^]
30 Oct 2013 by OriginalGriff
There are no real short cuts when it comes to stuff like this.Firstly, it seems to be organised in lines: so start by converting it to a collection of lines.string[] lines = File.ReadAllLines(path);Then, I would probably set up a Listfor each type you want to extract:List Points...
26 Jan 2014 by Sergey Alexandrovich Kryukov
You may need to remove '$', and then you can use double.Parse(string, System.Globalization.NumberStyles) with...
12 Feb 2014 by Sukhpal Singh JNU Jaipur
JSON parser classes creator tool for Android
17 Aug 2019 by honey the codewitch
Using PCK's grammar system, and understanding the concepts behind it
11 Jan 2020 by honey the codewitch
Using Parsley to prototype and test hand written parsers
10 Jan 2021 by Peter Belcak
Presenting the case for a generalized approach to parser construction from multiple parts
1 Aug 2021 by Matt Scarpino
Explains how to generate Python parsing code with ANTLR and use the code to create a Python parser in C++
14 Aug 2023 by Andre Oosthuizen
I will use regular expressions to match the key-value pairs in your input string, others might disagree with me. :) I have created a fiddle for you at - Reading string values in C#[^] using System; using System.Text.RegularExpressions; public...
31 Jan 2012 by Gregory Gadow
If you can translate the string into Latin numerals, you can then parse that string. I've never used internationalization and Unicode, but I would think you could step through the string one character at a time and use a case statement to compare and translate. Rebuild the string using a...
7 Sep 2012 by Sergey Alexandrovich Kryukov
There are can be at least two completely different things which may give different results. It depends on what you really need. (It's a good idea to start all questions from explanation of your ultimate purpose.)First one is: you can extract dependency information as it is prescribed in the...
4 Oct 2012 by JackDingler
It looks like you're getting your records in multiple packets, and appending a '\0' to each packet.Don't do that. You have fixed length records. Append the packets according to the exact number of bytes that the recv statement returns to you.You should not be inserting extra...
30 Oct 2013 by Member 10370776
Hi All,I'm completely new to programming in C# and have this question of how to go about parsing a .txt file?My .txt file looks something like thisValue 29.500000ID ...
12 Jun 2015 by CHill60
Try thisstring input = "9000384454|130945522842|13098575900|917379563772|919014742532|99484575475";var items = input.Split(new []{'|'}, StringSplitOptions.RemoveEmptyEntries);listBox1.DataSource = items;
13 Aug 2015 by Sergey Alexandrovich Kryukov
You cannot do it in any simple way. In some interpretive languages, and even in some compiling languages, this is a fundamental feature, but C++ is not one of them.You will need to create some compiler or interpreter to parse and execute your string. You can start here:...
20 Sep 2015 by PIEBALDconsult
Right, well obviously that method can't handle C/C++/C# syntax; it's actually pretty limited in what it can do.Fortunately, .net allows you to compile code at run-time. There are several articles here on CP, including mine: Compiling Source Code from a String[^]
3 Aug 2016 by Vyacheslav Chernykh
F#-implementation of algorithm for incremental construction of minimal deterministic finite automata through adding and removing strings.
17 Jan 2017 by Liu Junfeng
A PEG parser combinator library implemented in Rust, using operator overloading without macros.
21 Jul 2019 by honey the codewitch
Quickly build simple parsers with this drop-in source
14 Aug 2019 by honey the codewitch
An LALR(1) parsing algorithm as part of Pck
31 Jan 2020 by honey the codewitch
A small library for providing baseline Context-Free Grammar computations
13 May 2020 by Richard Deeming
Simple: XDocument doc = new XDocument( new XDeclaration("1.0", "utf-8", null), new XElement("root", new XElement("Textbox", YOUR_TEXTBOX_VALUE_HERE), new XElement("combobox1", YOUR_COMBOBOX1_VALUE_HERE), new...
4 Sep 2020 by Ahmed Bouchefra
How to remove comments from JSON using Python
8 Nov 2021 by Maciej Los
I'd suggest to read this: pandas.DataFrame.pivot — pandas 1.3.4 documentation[^]
30 Jan 2012 by MohammadAmiry
Hi,I would like to use .net Long.Parse("١٢٣٤٥٦٧٨٩٠") to get 1234567890 but it gives an error and does not recognizes these Indic digits as numbers.How can I do that?Thanks,Mohammad Amiry
28 Mar 2012 by JF2015
What you need is a mathematical expression parser. For example these ones:An extensible math expression parser with plug-ins[^]Inside the Mathematical Expressions Evaluator[^]http://www.bestcode.com/html/bcparser_net.html[^]
28 Mar 2012 by Clifford Nelson
I have several articles on value converters for evaluating expressions. they should be helpful, and they point to other options. I generally used the Javascript eval function. There is also an article on using Roslyn. Value Converter to Evaluate User Equation Input[^]Using Roslyn...
30 Mar 2012 by ProEnggSoft
For this purpose the expression evaluator can be used.This article may be helpful to youmath / function / boolean /string expression evaluator[^]From the following paragraph of the above article"Thus, I've developed a set of simple classes called ExpressionEval and FunctionEval....
10 May 2012 by Maciej Los
Almost each tag in html must contain ending tag, for example:My first HTML documentHello!As you see, for tag equivalent tag is More at:...
16 May 2012 by Wendelius
If I understood correctly, you can cast an object instance to your interface like:testinterface someVar = originalVar as testinterface;after that someVar should contain the variable as your interface if the original instance implemented the interface. If it didn't, someVar is null.
11 Jun 2012 by sathish.parthiban
Better try like below.DateTime ExDate = DateTime.ParseExact(txtExpiryDate.Text, "dd/MM/yyyy", null); (or) DateTime ExDate = Convert.ToDateTime("txtExDate".Text);
30 Aug 2012 by JackDingler
Load a line of the file into a character buffer.Use strstr(szBuffer, "from") to find the pointer to the "from" substring.Add strlen("from") to the pointer.This will give you the approximate location of the text you want.Example - Untested, just banged it out. Some debugging may...
15 Oct 2012 by Stefan_Lang
You could use std::find/[^] to locate occurences of 'Ì', and then remove it with an appropriate function: if the data type is std::string, then use string::erase[^], otherwise use a simple loop to shift the rest of the string one position to the left.
10 Dec 2012 by adama74
I'm also working on a similar task - mine is to extract test-nodes from html/cshtml/aspx/etc. type files.So far, I am using the HtmlAgilityPack to parse the HTML - but how to distinguish Razor markup from plain-text during parsing - THAT is the question.I haven't tried it out yet, but one...
10 Dec 2012 by Philippe Mori
I think that you are trying to use the wrong tool for the job...It make no sense to parse razor code to modify it. Use master pages, html helpers or maybe your own sequence that you would scan. Or better, why not uses razor itself to generate your code?You simple need to add in your...
20 Jan 2013 by OriginalGriff
No.There is no such thing as a "parser for any file format", and though it would be possible to create a class that could be expanded to parse new formats, there are so many different formats (just the number of different file formats Microsoft have used over the years is staggering) that it...
6 Mar 2013 by PIEBALDconsult
I'd use a Regular Expression. \$\(F\(\"(?'X'[^\"]*?)\",\s*\"(?'Z'[^\"]*?)\"\)\s*\)But you may want more flexibility.And we have a Regular Expressions forum here as well.
16 Jun 2013 by Thomas Daniels
Please see:http://stackoverflow.com/a/590789[^]http://stackoverflow.com/a/590789[^]Entire HTML parsing is not possible with regular expressions, since it depends on matching the opening and the closing tag which is not possible with regexps.Regular expressions can only match regular...
6 Jul 2013 by pasztorpisti
You shouldn't write an executable exporter. You should export the game data of each game that can be used by the very same executable. After this you can pack the data for example into a zip file and you can append it to the executable if you want a single-file game. If you are concerned that...
21 Jul 2013 by Simon Jackson
After playing a lot with Parse over the last few weeks, I thought I’d share some of my findings.
17 Aug 2013 by OriginalGriff
C# does not compile directly to native code - it compiles to an Intermediate Language which is later converted to the native instructions by the JIT compiler.If you what to view the IL, that's one thing - and it's easy enough to do - but you can't look at the native code because it isn't...
30 Oct 2013 by Richard MacCutchan
The first thing you will need is a StreamReader[^] to read the file, either one line at a time with ReadLine[^] or all in one go with ReadToEnd[^]. You can then use methods of the String[^] class to find specific lines and split the text into separate fields. Finally use the Double.Parse[^]...
6 Dec 2013 by OriginalGriff
There is no automatic way to do this: but it looks pretty simple to parse.I'd start by splitting it into separate Tickets, by using string.Split on the "--", then processing each of the Tickets into separate lines, then each line into Key and Value pairs using the ":" character.It's not...
27 Jan 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
ProblemsCondition is wrong. Instead of...Date.parse(startDate)
2 Jun 2014 by Member 2706889
How about you use the actual Razor template engine to do the job for you.Make sure you haveusing System.Web.Razor;and then something like thatRazorEngineHost _host = new RazorEngineHost(new CSharpRazorCodeLanguage());RazorTemplateEngine templateEngine = new...
29 Oct 2014 by Nosey Parker
Crafting on hex string
12 Nov 2014 by Jochen Arndt
The ValidDate function is obviously not doing what it should do. Using indenting you should see it (and your compiler should also show a warning when set to higher warning level):bool correctFormat = false;if (dates[2] == '/' && dates[5] == '/' && length == 10) if (correctFormat ==...
27 Nov 2014 by Sergey Alexandrovich Kryukov
You need to 1) open the file, 2) parse XML; 3) close the file. In your SAX handler, replace you System.out.println(...) with the statement writing to the file.Let's consider writing to the file separately, parsing separately, and the put it all together.First, let's assume you want to...
18 Mar 2015 by F-ES Sitecore
You can download the html from a page using the WebClientSample code for getting HTML via webclient[^]Once you have the source it's up to you. You can use regular expressions to identify the divs etc that contain the prices, or you can use basic techniques like IndexOf to search for the...
8 May 2015 by Maciej Los
Try this:string orgCodes = string.Join(",", xDoc .Root .Descendants("userGroup") .Select(a=> a.Attribute("orgCode").Value));Result:111,ABC-123,QRX-567,BB1
21 May 2015 by Mathi Mani
Hi,This solution will the parse the XML, CSV file and have the data in a datatable. You can change it to any form that suits your requirement. Here are the steps:Parsing XMLParse the XML and keep the column names in a List for selecting the required columns once CSV file is parsed. In...
13 Jun 2015 by OriginalGriff
The problem is that you aren't breaking it very well - look at your code.You declare temp and an array of 100 "pointer-to-char" values, and you use strcpy to copy the whole remaining line into it:strcpy(temp[posTok],&input[pos]);But...you never assign any values to the pointers, so they are...
8 Sep 2015 by Andy Lanng
This string is in JSON format. Look for a JSOn parser. I use newtonsoft. It's well documented, easy to use and best of all - FREE ^_^http://www.newtonsoft.com/json[^]Don't forget to check the license though:https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md[^]
22 Sep 2015 by F-ES Sitecore
You have two issues...one you are not coding defensively so are prone to these errors. There is no guarantee that your session variables exist so you have to check first. Secondly it looks like you might be storing ints as strings, which you shouldn't. To store an int...
15 Oct 2015 by Andreas Gieriet
Replace the double \ by one \. You are in a C# verbatim string (@"..."), so, each character is taken as is - no escaping needed (except for " which must be doubled for escaping). See also Escaping in C#: characters, strings, string formats, keywords, identifiers[^].CheersAndi
17 Oct 2015 by Andreas Gieriet
You may employ LINQ to objects, e.g.string filein = @"datain.txt";var sorted = from line in File.ReadAllLines(filein) let record = Tuple.Create(double.Parse(line.Split(',')[1]), line) orderby record.Item1 select record.Item2;string...
4 Aug 2016 by Richard MacCutchan
Use a pointer to skip the prefix alphabetic characters, then use strtol[^] to convert the number to a long value. The endptr variable will then point to the first non-numeric character, allowing you to parse further. Something like:char* strData = "*H1999999#";char* strNum = strData +...
15 May 2017 by Ravi Bhavnani
I wrote (and currently use) these classes: WebResourceProvider goes .NET[^] StringParser[^] to allow me to consume data from a web site. However, please ensure that you have permission from the owners of the website to scrape data for use by your app. You may also want to consider simply...
13 Jan 2018 by Thomas Daniels
Your code is:debugOutput("Name: " + jPerson.Name); But your property definition is: public string name { get; set; } So that's name rather than Name: C# identifiers are case-sensitive.
18 Jan 2018 by Graeme_Grant
This article goes into detail on how to Deserialize JSON and the tools that you can use to help you: Working with JSON in C# & VB[^] Here is the code generated by JSON Utils: Generate C#, VB.Net, SQL Table, Java and PHP from JSON[^]: namespace WhitePagesTool {         public class BelongsTo...
10 Nov 2018 by Richard MacCutchan
This is your assignment so you are expected to do the work. If you really do not understand it then you should be talking to your teacher.
8 Nov 2019 by Richard MacCutchan
Multithreading is not guaranteed to make a great difference, and will depend on what your code is doing. The first thing to look at is where the slow processing actually occurs. Is the delay due to the speed of getting the data off disk, or in processing it once it's in memory?
31 Jan 2020 by honey the codewitch
Add fast scanners/tokenizers to your C# project
17 May 2020 by Garth J Lancaster
probably 1) Get a file/path using a dialog SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments); saveFileDialog1.Filter = "Your extension here...
27 May 2020 by RickZeeland
Although Data Binding is the recommended way, you could do it like the example taken from: Export DataGridView to XML File without any DataSet or DataTable ...[^] private DataTable GetDataTableFromDGV(DataGridView dgv) { var dt = new...
27 May 2020 by Maciej Los
First of all, you'll never be good programmer, if you're trying to use the piece of code by copy-paste and without changing code on your own. Second of all, your DataGridView control is bind to none DataSource, because you're adding rows...
8 Jul 2020 by OriginalGriff
Quote: I guess you need to dig towards regular expressions. I guess you need to dig towards regular expressions - it isn't my homework, and I can already use them. If you want to get started with Regexes, then get a copy of Expresso[^] - it's...
24 Mar 2021 by k5054
Problem one seems to be a mix of UTF-8 and ASCII quotation marks (") in your code -- assuming you did a cut&paste from your source. Next, your logic is slightly off. You break the while loop and report no matches on the first non-match. One...
30 Jun 2021 by Richard MacCutchan
If you do not understand an issue with a .NET control then you should first check the documentation: Control.Show Method (System.Windows.Forms) | Microsoft Docs[^].
30 Jun 2021 by Dave Kreskowiak
Read up on the documentation for the Label control. You change the text a label shows by setting it's Text property to a string. You would normally NEVER call Show() on a label.
13 Sep 2022 by Richard MacCutchan
The problem is that each entry in your skill_list is a list with one element, inside a list, inside another list. So to access the actual words you need: for skill in skill_list[0]: print(skill[0])
5 Oct 2022 by OriginalGriff
Try this: \btvg-name="([^"]+)".tvg-logo="([^"]+)".group-title="([^"]+)",(.*?)\n*(https?\S+) If you are going to work with regexes, get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.