When working with regular expressions, it can be difficult to understand why a particualar pattern is not working as you would expect.
The visual debug tool at debuggex.com makes it much easier to step through and actually visualize how a pattern is working or, as is often the case, not working.
Here is an overview of how it works.
If you are developing a plugin on WordPress, you will need to debug your code as you go.
To enable debugging, go to your wp-config.php file.
Find the line…
Replace the line above with the following…
// Turns WordPress debugging on
// Tells WordPress to log everything to the /wp-content/debug.log file
// Doesn't force the PHP 'display_errors' variable to be on
// Hides errors from being displayed on-screen
Now you all warnings and errors will show up in the /wp-content/debug.log file, including WordPress warnings of deprecated functions.
You can write directly to this log from your plugin using the
//output some debug string
error_log( 'this works yo' );
//output some array/object
error_log( print_r( $some_obj_or_array, 1 ) );
Kudos to this post. It has some good plugin development tips, including how to enable debugging on WordPress.
This is a super simple command but there is something about the following sequence of characters that I simply cannot retain in my brain.