Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i replace %0A with <br>

Status
Not open for further replies.

Vesku

Programmer
Jun 7, 2000
19
0
0
FI
Hi !<br><br>When i read form with Perl:<br><br>read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});<br>@pairs = split(/&/, $buffer);<br>foreach $pair (@pairs) {<br>($name, $value) = split(/=/, $pair);<br>$value =~ tr/+/ /;<br><br># $value =~ tr/%0A/&lt;br&gt;/;<br><br>$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;<br>$FORM{$name} = $value;<br>}<br><br>, how can i replace 'Enter' with &lt;br&gt;. I tried $value =~ tr/%0A/&lt;br&gt;/; but it does not work.<br><br><br>Any ideas ???<br><br>Thanx!
 
Hi Vesku,<br><br>I think that:<br><FONT FACE=monospace><b><br>$value =~ s/\n/&lt;br&gt;/;<br></font></b><br>should do it.<br><br>You can also remove the enter (the newline character &quot;\n&quot;) with:<br><FONT FACE=monospace><b><br>chomp($value);<br></font></b><br>you could then add your html code with <FONT FACE=monospace><b>$value .= '&lt;br&gt;';</font></b><br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Hi Mike !<br><br><b>$value =~ s/\n/&lt;br&gt;/;</b> works only if you have one 'enter' in your data.<br><br>My situation is this:<br><br>I have textfield and i want replace <b>all</b> %0A with &lt;br&gt;.<br><br><br>When i write to textfield and press enter when i want new paragraph, output is:<br><br><b>paragraph1 paragraph2 paragraph3</b><br><br>, but datafile looks:<br><br><b>paragraph1<br>paragraph2<br>paragraph3</b><br><br>I want that datafile looks:<br><br><b>paragraph1&lt;br&gt;paragraph2&lt;br&gt;paragraph3</b><br><br><br>Vesku!<br>
 
Try putting a 'g' on the end of the 's' command to make it global.&nbsp;&nbsp;ie;<br><FONT FACE=monospace><br>$value =~ s/\n/&lt;br&gt;/g;<br></font><br>That should replace all &quot;\n&quot; characters in the text. <p> <br><a href=mailto: > </a><br><a href= > </a><br>--<br>
0 1 - Just my two bits
 
that'll do it &lt;s&gt; <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top