html entity conversion... one liner?

2002-01-31 Thread KAVANAGH, Michael
I thought it would be good to be able to do this: $item = ""; $item =~ tr/<>/(<)(>)/; to convert those <> symbols to their entity references. however, the tr operator doesn't seem to like using () to group... any comments on how to make this operation in to a one-liner? Thanks Mike -- To u

RE: html entity conversion... one liner?

2002-01-31 Thread John Edwards
$item =~ s//>/g; Well. It is on one line ;) John -Original Message- From: KAVANAGH, Michael [mailto:[EMAIL PROTECTED]] Sent: 31 January 2002 14:06 To: '[EMAIL PROTECTED]' Subject: html entity conversion... one liner? I thought it would be good to be able to do

Re: html entity conversion... one liner?

2002-01-31 Thread Chas Owens
On Thu, 2002-01-31 at 09:06, KAVANAGH, Michael wrote: > I thought it would be good to be able to do this: > > $item = ""; > $item =~ tr/<>/(<)(>)/; > > to convert those <> symbols to their entity references. > however, the tr operator doesn't seem to like using () to group... any > comments on

Re: html entity conversion... one liner?

2002-01-31 Thread Briac Pilpré
On Thu, 31 Jan 2002 14:06:06 -, Michael Kavanagh <[EMAIL PROTECTED]> wrote: > I thought it would be good to be able to do this: > > $item = ""; > $item =~ tr/<>/(<)(>)/; > > to convert those <> symbols to their entity references. however, the > tr operator doesn't seem to like using () to g

RE: html entity conversion... one liner?

2002-01-31 Thread John Edwards
( '<' => '<', '>' => '>', '&' => '&', ); $item = ""; $item =~ s/([<>&])/$entity{$1}/ge; which isn't even a one liner as you have to define a lookup hash to b

Re: html entity conversion... one liner?

2002-01-31 Thread John W. Krahn
Michael Kavanagh wrote: > > I thought it would be good to be able to do this: > > $item = ""; > $item =~ tr/<>/(<)(>)/; tr/// will translate the '<' to a '(' and the '>' to a '&'. > to convert those <> symbols to their entity references. > however, the tr operator doesn't seem to like using (

RE: html entity conversion... one liner?

2002-01-31 Thread Chas Owens
ier to extend than individual regexs if you are defining a lot of entities (that is why my example had an & in it). Of course you should probably not be doing any of this yourself; I am sure a module exists out there to handle this sort of case. > > All IMHO ;) > > John > >

RE: html entity conversion... one liner?

2002-01-31 Thread Bob Showalter
> -Original Message- > From: KAVANAGH, Michael [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 31, 2002 9:06 AM > To: '[EMAIL PROTECTED]' > Subject: html entity conversion... one liner? > > > I thought it would be good to be able to do thi

RE: html entity conversion... one liner?

2002-02-01 Thread Chas Owens
s not a one liner, but it does look nicer and is easier to > extend than individual regexs if you are defining a lot of entities > (that is why my example had an & in it). Of course you should probably > not be doing any of this yourself; I am sure a module exists out there > to