Archive

Archive for April, 2010

Great Tip : Opening Multiple Instances of an Application from the Windows Taskbar

April 25th, 2010 No comments

Tip 1:-
I always need several Cygwin Windows open so I was very frustrated by Windows 7 only allowing me to open one Cygwin from the Windows 7 Taskbar. This is because once you click on an icon it disappears from the Taskbar! This is different to the behavior of the previous XP or Vista Taskbar and often prompts users to select the Vista Taskbar compatibility. There is fortunately a work around depress the SHIFT button and then click the existing open icon on the taskbar and voila you will spawn a application window!

Tip 2:-
The Properties Tab is HIDDEN on the Windows 7 Taskbar and had me hating it until I found it. Rightmouse click the relevant Application Icon on the Taskbar then hover over the revealed tab and Right Mouse Click this and there magically is the Properties Tab!!

Perl: Regexp to filter out/match just the price/floating point number ie digits and dots

April 15th, 2010 No comments

There are two ways:-

$price=~tr/0-9.//cd; # delete anything but 0-9 and a real dot

$row_array[6]=~s/[^0-9.]//g; # clean up price, remove pound/dollar sign etc

Categories: Uncategorized Tags: , , ,

Parsing HTML with preg_match

April 8th, 2010 No comments

preg_match_all(‘#<b>.+?</b>#i’, $html, $matches);
// ? means non-greedy and is absolutely critical

$match[1], $match[2] contain the results

Non greedy stops the match gobbling everything between the first bold tag and the very last. I’ve never quite understood why greedy is the default behavior of RegExp (Regular Expressions) but I guess there’s a good reason for it.

PHP also has the very useful strip_tags function.

Categories: Coding Tips, PHP Tags: