Regex, how do I replace quotation pairs into <LI> & </LI>?

Discussion in 'Perl' started by Kelvin, Oct 21, 2004.

  1. Kelvin

    Kelvin Guest

    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
     
    Kelvin, Oct 21, 2004
    #1
    1. Advertising

  2. Kelvin wrote:
    > Basically, my texts consists of normal text stream and some
    > quotations.


    Answered in comp.lang.perl.misc only, since this group is defunct.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Oct 21, 2004
    #2
    1. Advertising

  3. Kelvin

    Tore Aursand Guest

    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


    --
    Tore Aursand <>
    "Time only seems to matter when it's running out." (Peter Strup)
     
    Tore Aursand, Oct 21, 2004
    #3
  4. Kelvin

    Gerhard M Guest

    "Kelvin" <> wrote in message news:<41778d70$>...
    > 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
     
    Gerhard M, Oct 21, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Enjoy Life

    Replace function for double quotation mark.

    Enjoy Life, Apr 14, 2004, in forum: ASP General
    Replies:
    33
    Views:
    526
    Ray at
    Apr 15, 2004
  2. Johan Martinez
    Replies:
    3
    Views:
    292
    Johan Martinez
    May 22, 2011
  3. Kelvin
    Replies:
    4
    Views:
    101
    Gerhard M
    Oct 21, 2004
  4. Scott Bass
    Replies:
    10
    Views:
    232
    Brian McCauley
    May 30, 2005
  5. Tim
    Replies:
    4
    Views:
    625
    Jukka K. Korpela
    Nov 4, 2011
Loading...

Share This Page