help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to use parsing expressing grammar


From: Kevin Rodgers
Subject: Re: how to use parsing expressing grammar
Date: Wed, 17 Dec 2008 20:43:28 -0700
User-agent: Thunderbird 2.0.0.18 (Macintosh/20081105)

Xah Lee wrote:
There are 2 parsing expression grammars in elisp.

    * http://www.emacswiki.org/cgi-bin/wiki/ParserCompiler, (2008) by
Mike Mattie.
    * http://www.emacswiki.org/emacs/ParsingExpressionGrammars (2008)
by Helmut Eller.

The second one seems simpler, and i'm trying to learn it as a regex
replacement, but don't know how to use it.

Could anyone give concrete example in the following scenario?

For example, on my website i have things like:

 <hr>
 <p>Related essays:</p>
 <ul>
 <li><a href="someFilePath1">SomeTitleString2</a> someSring1</li>
 <li><a href="someFilePath2">SomeTitleString2</a> someSring2</li>
 ...
 </ul>

Suppose i want to change them to:

 <hr>
 <p>See also:</p>
 <p>
 <a href="someFilePath1">SomeTitleString1</a> someSring1<br>
 <a href="someFilePath2">SomeTitleString2</a> someSring2<br>
 ...
 </p>

How do i do it?

Choose the right tool for the job:

sed -e 's|^<p>Related essays:</p>$|<p>See also:</p>|' -e '/^<ul>$/,/^<\/ul>/{s|^<\(/*\)ul>$|<\1p>|;s|^<li>||;s|</li>$|<br>|;}'

And since this is help-gnu-emacs@gnu.org:

C-x h
C-u M-| sed -e ...

--
Kevin Rodgers
Denver, Colorado, USA





reply via email to

[Prev in Thread] Current Thread [Next in Thread]