[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] 5.10 - vertical, horizontal whitespace
Ooo, neat. Hadn't noticed these additions to 5.10...
http://perldoc.perl.org/perlrebackslash.html
• \h Character class for horizontal whitespace.
• \H Character class for non horizontal whitespace.
• \v Character class for vertical whitespace.
• \V Character class for non vertical whitespace.
That could come in really hand on occasion.
Jay Hannah
Software Architect
jhannah@mutationgrid.com | http://mutationgrid.com | 1-402-598-7782
IRC freenode #bioperl
14:53 < dbolser> how do I stop /s+ matching the final /n?
14:53 < dbolser> s/\s+/\t/g
14:55 * dbolser asks in perl
14:58 <@pyrimidine> dbolser: on modern perl I think you can use \N\
14:58 <@pyrimidine> * \N
14:59 < dbolser> Missing braces on \N{} at
15:00 < dbolser> Quantifier follows nothing in regex; marked by ...
15:00 < dbolser> I guess I'm not modern
15:00 <@pyrimidine> Nope, I'm wrong
15:00 <@pyrimidine> \N is for Unicode. There is something added recently, though
15:01 <@pyrimidine> no, actually I was correct :) http://perldoc.perl.org/perlre.html
15:02 <@pyrimidine> \N has two meanings in perl 5.12 (not sure if this is in 5.10, but I know it isn't in 5.8)
15:02 <@pyrimidine> dbolser: you can always use a character class instead
15:04 < dbolser> pyrimidine: I found 'the easy way' ;-)
15:04 < dbolser> s/ +/\t/g;
15:04 < dbolser> funny how the blindingly obvoius is easy to miss at times
15:04 <@pyrimidine> what if you have \s\t?
15:05 <@pyrimidine> :)
15:05 < dbolser> I don't
15:05 < dbolser> afaik
15:06 <@pyrimidine> I was thinking something like s/[ \t]+/\t/g
15:08 <@pyrimidine> dbolser: perl 5.10 has a way to match vertical and horizontal whitespace, using \v and \h, so that could probably be s/\h+//g (if you have 5.10. that is)
15:08 <@pyrimidine> http://perldoc.perl.org/perlrebackslash.html
15:17 < dbolser> pyrimidine: right