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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping chr(10)

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
Code:
$INTEST =~ s/[^a-zA-Z0-9@\/.,: <>&()-]//g;
$INTEST=~ s/\n//g;
$INTEST=~ s/\r//g;
This is allowing chr(10) through, what am I missing?

Keith
 
Not sure, clutchalert=True;

Try putting the first line at the end ...

\n==>chr(10)
\r==>chr(13)

looks fine to me

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Aren't the second and third replacements superfluous, as those characters should be removed by the first regexp anyway?

Either way, a transliteration is probably more efficient, since you're only replacing single characters:

Code:
 $string =~ tr/a-zA-Z0-9@\/.,: <>&()-//cd;
 
Can you give us a sample of the bogey string?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Don't we need the /m switch to process multilines?

Other wise we are processing aline at a time and don't see the \r or \n

Jeb
 
Do I need the /m switch to process multi lines?

Sorry chaps, it was me being a dummy.
I had an old record in my table with a line feed in it and that was the cause of the erratic behaviour.
Thanks anyway.

Keith
 
/m would be only if you're reading from a file I would have thought.

I've had no problems replacing "\n"'s in a string, coulda been just lucky I guess

--Paul

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top