Click here to get back home

Regex, how do I replace quotation pairs into
  • &
  • ?

     HomeNewsGroups | Search | About
     comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
    Subject Author Date
    Regex, how do I replace quotation pairs into
  • &
  • ?
    Kelvin 10-21-2004
    Get Chitika Premium
    Posted by Kelvin on October 21, 2004, 7:27 pm
    Please log in for more thread options
    Basically, my texts consists of normal text stream and some quotations.

    This is my text stream, and inside "this streams" there are some "quotation
    pairs"
    which are to be replaced like this: <LI>this streams</LI> for formatting in
    HTML.

    Tried ___s/".*?"/<li>.*?</li>/g;___ but not working.

    Thanks.
    Kelvin








    Posted by Gerhard M on October 21, 2004, 10:56 am
    Please log in for more thread options
    > Tried ___s/".*?"/<li>.*?</li>/g;___ but not working.

    hi kevin

    try
    s#"([^"]*)"#<li>$1</$1>#g

    matches " (any text but quotes) "
    and places (any text..) between <li> and </li>

    gerhard


    Posted by Gunnar Hjalmarsson on October 21, 2004, 2:16 pm
    Please log in for more thread options
    Kelvin wrote:
    > Basically, my texts consists of normal text stream and some
    > quotations.

    Answered in comp.lang.perl.misc only, since it seems to have little to
    do with modules.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl


    Posted by Tore Aursand on October 21, 2004, 3:45 pm
    Please log in for more thread options
    On Thu, 21 Oct 2004 18:27:05 +0800, Kelvin wrote:
    > s/".*?"/<li>.*?</li>/g;

    No need to escape those "-characters, AFAIK. And you don't want to
    replace .*? above with - uhm - the regular expression .*?, do you?

    Untested, but I think something like this should do it;

    s,"(.*?)",<li>$1</li>,g;

    Please read these:

    perldoc perlretut
    perldoc perlre


    --
    "Time only seems to matter when it's running out." (Peter Strup)


    Similar ThreadsPosted
    Re: How to replace a "/" in perl March 15, 2007, 10:40 pm
    "reverse templating" or "auto-meta-regex" module for automated screen-scrape learning? September 18, 2007, 10:09 pm

    Our other projects:

    Art Dolls, Fairies and Mermaids - Sunnyfaces.net

    Roy's Linux, Programming and Search Engines messages

    1-Script XML SitemapXML Sitemap