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

K

Kelvin

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
 
G

Gunnar Hjalmarsson

Kelvin said:
Basically, my texts consists of normal text stream and some
quotations.

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

Tore Aursand

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
 
G

Gerhard M

Kelvin said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top