Skip to Main Content
Eloquent JavaScript
book

Eloquent JavaScript

by Marijn Haverbeke
January 2011
Intermediate to advanced content levelIntermediate to advanced
224 pages
5h 43m
English
No Starch Press
Content preview from Eloquent JavaScript

Parsing an .ini File

Now let’s look at a real problem that calls for regular expressions. Imagine we are writing a program to automatically harvest information about our enemies from the Internet. We will not actually write such a program here, just the part that reads the configuration file. This file looks like this:

searchengine=http://www.google.com/search?q=$1
spitefulness=9.7

; comments are preceded by a semicolon...
; these are sections, concerning individual enemies
[larry]
fullname=Larry Doe
type=kindergarten bully
website=http://www.geocities.com/CapeCanaveral/11451

[gargamel]
fullname=Gargamel
type=evil sorcerer
outputdir=/home/marijn/enemies/gargamel

The exact rules for this format (which is actually a widely used format, usually called ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Eloquent JavaScript, 3rd Edition

Eloquent JavaScript, 3rd Edition

Marijn Haverbeke
Learn JavaScript

Learn JavaScript

Shaun Wassell

Publisher Resources

ISBN: 9781593272821Errata