Remove JavaScript Tags From HTML

After a while of trying to create the perfect regular expression that would remove script tags from HTML I came across this super simple regular expression. It goes to show you, sometimes the simplest things work best.

s = Regex.Replace(s, "", "",RegexOptions.Singleline|RegexOptions.IgnoreCase);

Source: http://forums.asp.net/t/1323604.aspx/1

Remove Trailing Slash From URL In Htaccess

This is a simple one and it’s relative to the user’s current location. This is important because you don’t want to hard-code your website’s URL onto the htaccess file. The main reason being because you don’t want to switch the user over to an HTTP connection when they are in a HTTPS connection.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)/$ /$1 [R=301,L]

Matching Complete Words With RegEx

This is a useful tip for when you want to match a word to another word exactly. For example say I want to match the word ‘digit’ in a MySQL query. In a normal LIKE query the word ‘digitize’ would throw a match. We know these two words are NOT the same thing and therefore should not create a match. This is how we would create a query looking for an exact match of the word ‘digit’.

SELECT * FROM `mytable` WHERE `field` REGEXP '[[:<:]]myword[[:>:]]';