Whitespace mystery?

S

squash

I have some strings that have trailing whitespaces which this regex is
not matching:

$string =~ s/\s+$//; ## Remove trailing white spaces

I have tried \n and \t but with no luck. What could those whitespaces
be?

Thx!
 
J

jl_post

I have some strings that have trailing whitespaces which
this regex is not matching:

$string =~ s/\s+$//; ## Remove trailing white spaces

I have tried \n and \t but with no luck. What could those
whitespaces be?


At this point, we can only guess.

Do us a favor (so that we can help you out). Put the following code in
your program right before your regexp:

print " \$string = \"$string\"\n";
print " $_\n" foreach map ord, split //, $string;

Then give us the output from these two lines. This will help us figure
out what is contained in your $string variable. (You may also want to
put those lines AFTER the regular expression as well, and send us that
output too.)
 
S

squash

Thanks for the quick reply! Here's the output:

$string = "VS1 " 86 83 49 160 (before regex)
$string = "VS1 " 86 83 49 160 (after regex)
 
S

squash

Thanks, I have figured it out. I added in this line to remove the ASCII
160 characeter for &nbsp:

$string =~ s/\xA0//; ## Remove html &nbsp blank space (A0 hex for 160)
Thx!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top