Durai wrote:
> 
> Hello All,

Hello,

> I am having the following lines of code to remove "\n" from string.
> 
> $_="Hi. \n This is test string";
> s/
>  (\n)
>  /HI
> /xisg;
> 
> print;
> 
> I expected the output like:
> 
> Hi. HI This is test string
> 
> But I got:
> 
> Hi. HI
>  This is test string
> 
> Anything wrong?

It looks fine to me.

$ perl -le'$_="Hi. \n This is test string"; s/ (\n) /HI/xisg; print'
Hi. HI This is test string


But of course, you don't need the /i option because there are no letters
in the regular expression and you don't need the /s option because you
are not using . in the regular expression and you don't need the
parentheses because you are not grouping or capturing anything.

$ perl -le'$_="Hi. \n This is test string"; s/ \n /HI/xg; print'
Hi. HI This is test string



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to