A non-breakable space is, by definition, non-breakable :) -
\s simply doesn't match. You can substitute it with plain spaces if you want. The following snippet will work with both decoded and encoded chunks of text:
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Entities qw( decode_entities );
my $EncodedDate = "Tue Sep 13, 2005 10:38
pm";
my $MixedDate = $EncodedDate . "\n------\n" . decode_entities($Encoded
+Date);
# $nbsp will contain the decoded version of
decode_entities(my $nbsp = ' ');
# Now, substitute all flavours of non-breakable-spaces
$MixedDate =~ s/ |$nbsp/ /g;
# Same split as before
my @date = split /\s+/, $MixedDate;
print "$_ $date[$_]\n" foreach 0 .. $#date;
__END__
0 Tue
1 Sep
2 13,
3 2005
4 10:38
5 pm
6 ------
7 Tue
8 Sep
9 13,
10 2005
11 10:38
12 pm
You'd probably prefer to
split on
/[\s:,]+/, anyway: it will get rid of the comma after the "13", and will split "10:38" as well.
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Don't fool yourself.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.