Re: Perl regex question
- From: James <hslee911@xxxxxxxxx>
- Date: Fri, 21 Jan 2011 12:27:45 -0800 (PST)
On Jan 21, 12:17 pm, James <hslee...@xxxxxxxxx> wrote:
$ cat subst.pl
%replace = ('<' => '<', '>' => '>', '\s+' => '<td>');
s/(<|>|\s+)/$replace{$1}/g;
$ echo "< hello >" | perl -n ./subst.pl
(there's a space between < and hello)
I am trying to get
<<td>hello<td>>
but I got
<hello>
How do I get it right?
James
Opps, the HTML entities got translated.
Is there a vanilla mode in posting?
Let me re-phrase the question again.
$ cat subst.pl
%replace = ('<' => '\<', '>' => '\>', '\s+' => '<td>');
s/(<|>|\s+)/$replace{$1}/g;
$ echo "< hello >" | perl -n ./subst.pl
(there's a space between < and hello)
I am trying to get
\<<td>hello<td>\>
but I got
\<<hello>\>
How do I get it right?
James
.
- Follow-Ups:
- Re: Perl regex question
- From: Ben Bacarisse
- Re: Perl regex question
- From: James
- Re: Perl regex question
- References:
- Perl regex question
- From: James
- Perl regex question
- Prev by Date: Perl regex question
- Next by Date: Re: Perl regex question
- Previous by thread: Perl regex question
- Next by thread: Re: Perl regex question
- Index(es):
Relevant Pages
|