A common thing I need to do is insert text before and after a number of lines in a text editor. For example, I might have the following text:
test1
test2
test3
test4
test5
Which I want to change to something like this:
before_test1_after
before_test2_after
before_test3_after
before_test4_after
before_test5_after
So I’ve added the text before_ at the start of each line and the text _after at the end of the each line. To do this with Regex and Notepad++
- Open a new document, with the starting text.
- Choose Search > Replace (CTRL + H).
- Switch the search mode to Regular expression
To add text at the start of each line, search for ^(.) and replace with before_\1. This matches the start of the line and any character (.) after it. It replaces with the text before_ and the first match result \1.
Similarly to add text at the end of each line, search for (.)$ and replace with \1_after. This matches any character up to the end of the line. It replaces it with the search result followed by the text after_.
July 25, 2010 | In
General |
No Comments
The Joomla Administration pages, have, well, always been a bit poor. Not any more! You can make them look at lot better with the free AdminPraise Lite template available from JoomlaPraise. This doesn’t just make your administration pages look better, it actually makes them easier to work with by organising things better. Definitely worth trying out.
July 12, 2010 | In
General |
No Comments
By default on Apache web servers, PHP code will not execute in a file that does not have a .php (or similar) extension. So even though you can embed PHP into a HTML file, it won’t execute when the file extension is .html, .htm etc.
To change this, you can add a .htaccess file. Here’s some example code to add depending on your system:
For XAMPP:
AddType application/x-httpd-php .html .htm
For Hosting (obviously depends on your hosting provider):
Addhandler application/x-httpd-php5 .html .php
Put this in a file called .htaccess in the same folder as your HTML files.
July 1, 2010 | In
General |
No Comments
These are the basic steps for cloning a WordPress site. In this example, I assume your source web server is your live site on your web hosting and your target web server is your local development web server. Try to keep the same directory name and database name to keep things simple.
- Backup all of the files from your site on your web hosting and download (e.g. via FTP).
- Export your database to a SQL script (e.g. through phpMyAdmin for MySQL)
- Extract your files to your local development server directory
- (Create) and import your database using the exported SQL script (e.g. through phpMyAdmin for MySQL)
- If your database name or database user/password has changed, update wp-config.php in the main directory accordingly.
- Start your SQL tool (e.g. phpMyAdmin for MySQL). You will need to update the table wp-options. The two options you will be updating (option_name) are siteurl and home. Change these from the URL of your source site (live site) to your local development web server URL (option_value fields).
Hopefully your local development site is now working.
While redesigning this site, I incorporated a new print style sheet. During the process I discovered a feature in Firefox when printing a web site. Basically, if you have the overflow: hidden CSS attribute set, then it could prevent Firefox from printing all pages from the web site.
So, if you notice that you are only seeing a portion of your web site in your print preview, check your CSS code, and look for any cases where overflow: hidden has been set. For example, I had it set in my container div to allow the footer to always be placed right at the bottom of the page regardless of the content size above it.