Category Archives: Programming

Javascript Modular Design Patterns

Some resources explaining the modular design pattern in javascript, for future reference.

PHP IMAP: Using UID to get header info

Interesting that imap_headerinfo() does not allow a UID for the $msg_number field like all other fetching functions seem to allow.

If you want to use a UID to fetch the headers, use this two-step process:

<?php
/*
* assumes $mbox is your stream, and $uid is set
* properly. Proper error checking is up to you.
*/
$hText = imap_fetchbody($mbox, $uid, '0', FT_UID);
$headers = imap_rfc822_parse_headers($hText);
?>

The result is the same as the output of imap_headerinfo(), but you get to use the UID.

From: http://www.php.net/manual/en/function.imap-fetchheader.php

Using RegEx to replace HTML Tags

This regular expression matches the html italic begin and end tags as well as any text between them:
 <i>([^<]+)</i>

This regular expression will replace the found italic tags with beginning and end span tags of class ‘caseName’:
<span class=”caseName”>1</span>

The 1 represents the first group in the find expression (between the parenthesis), thus preserving the text between the tags. This may be unique to the regex in Notepad++. Other regex tools may use $1 instead.

Source: http://stackoverflow.com/questions/3218063/notepad-replace-problem