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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kelvin

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

    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






  • Gunnar Hjalmarsson

    #2
    Re: Regex, how do I replace quotation pairs into &lt;LI&gt; &amp; &lt;/LI&gt;?

    Kelvin wrote:[color=blue]
    > Basically, my texts consists of normal text stream and some
    > quotations.[/color]

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

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

    Comment

    • Tore Aursand

      #3
      Re: Regex, how do I replace quotation pairs into &lt;LI&gt; &amp; &lt;/LI&gt;?

      On Thu, 21 Oct 2004 18:27:05 +0800, Kelvin wrote:[color=blue]
      > s/\".*?\"/<li>.*?<\/li>/g;[/color]

      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 <toreau@gmail.c om>
      "Time only seems to matter when it's running out." (Peter Strup)

      Comment

      • Gerhard M

        #4
        Re: Regex, how do I replace quotation pairs into &lt;LI&gt; &amp; &lt;/LI&gt;?

        "Kelvin" <thefatcat28@ho tmail.com> wrote in message news:<41778d70$ 1@news.starhub. net.sg>...[color=blue]
        > Tried ___s/\".*?\"/<li>.*?<\/li>/g;___ but not working.[/color]

        hi kevin

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

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

        gerhard

        Comment

        Working...