$string = 'hi there [hello]this is my hello message[/hello][hello]this is another hello message[/hello]';
// Count the number of occurences:
$count = preg_match_all( '/\\[hello\\]/', $string, $dummy );
// Delete [hello] if not closed
// First replace closed matches, then delete remaining, then replace back
$string = preg_replace( '/\\[hello\\](.*)\\[\\/hello\\]/U', '[qwerty]$1[/qwerty]', $string );
$string = str_replace( '[hello]', '', $string );
$string = str_replace( 'qwerty', 'hello', $string );
echo "Count is: $count$string";
?>
Tuesday, September 15, 2009
PHP counting the # of word occurance in a string
How to disable/turn off Visual Studio .NET JIT Debugger
How to disable/turn off Visual Studio .NET JIT Debugger
* How to disable/turn off Visual Studio .NET JIT Debugger
Option 1: Registry key from Enabling JIT Debugging
For an application that includes managed code, the common language runtime will present a similar dialog to JIT-attach a debugger. The registry key that controls this option is called HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting.
If value = 0, prompt the user by means of a message box. The choices are:
Continue. This results in a stack dump and process termination.
Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none, control is returned, and the process is terminated.
If value = 1, simply return control. This results in a stack dump, after which the process is terminated. (No more dialog)
If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.
Option 2: If you want to disable the JIT debug dialog, but still want an error dialog:
Visual Studio.NET|Tools|Options|Debugging|Just-In-Time and deselect "Common Language Runtime" and now you’ll get an OK/Cancel dialog instead of the select a Debugger Dialog. Note: The registry entry from Option 1 above will need to be 0 for the dialog to show up.
*Disabling Visual Studio "Just In time Debugger"
Go to Tools -> Options -> Debugging -> Just-In-Time and disable VS as the JIT debugger.
* How to disable/turn off Visual Studio .NET JIT Debugger
Option 1: Registry key from Enabling JIT Debugging
For an application that includes managed code, the common language runtime will present a similar dialog to JIT-attach a debugger. The registry key that controls this option is called HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting.
If value = 0, prompt the user by means of a message box. The choices are:
Continue. This results in a stack dump and process termination.
Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none, control is returned, and the process is terminated.
If value = 1, simply return control. This results in a stack dump, after which the process is terminated. (No more dialog)
If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.
Option 2: If you want to disable the JIT debug dialog, but still want an error dialog:
Visual Studio.NET|Tools|Options|Debugging|Just-In-Time and deselect "Common Language Runtime" and now you’ll get an OK/Cancel dialog instead of the select a Debugger Dialog. Note: The registry entry from Option 1 above will need to be 0 for the dialog to show up.
*Disabling Visual Studio "Just In time Debugger"
Go to Tools -> Options -> Debugging -> Just-In-Time and disable VS as the JIT debugger.
Wednesday, September 2, 2009
parsing the google trends atom feed rss
$feed = simplexml_load_file('http://www.google.com/trends/hottrends/atom/hourly');
$children = $feed->children('http://www.w3.org/2005/Atom');
$parts = $children->entry;
foreach ($parts as $entry) {
$details = $entry->children('http://www.w3.org/2005/Atom');
$dom = new domDocument();
@$dom->loadHTML($details->content);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $anchor) {
$url = $anchor->getAttribute('href');
$urltext = $anchor->nodeValue;
echo 'Link: ' . $urltext . ' ';
}
}
Subscribe to:
Posts (Atom)