Sanibel Logic LLC

...Scalable Technologiesfor the Enterprise

Regular Expression String Encoding

Sanibel Logic has a number of products which utilize Regular Expressions.  One common question asked by licensees is how to encode Regular Expression strings within the web.config file.  Because the web.config conforms to rules for HTML encoding, any such string must first be HTML encoded, as provided by the .NET System.Web.HttpUtility.HtmlEncode method.  After the string is HTML encoded then we must consider Regular Expression special characters, which must be escaped and include the following special characters:

  • "\" - Backslash
  • "^" - Carat
  • "." - Period
  • "[" - Left bracket
  • "$" - Dollar sign
  • "(" - Left parenthesis
  • ")" - Right parenthesis
  • "|" - Pipe
  • "*" - Asterisk
  • "+" - Plus
  • "?" - Question mark
  • "{" - Left curly bracket

SSLRedirect uses Regular Expression values within the web.config SSLRedirect configuration section, within the urlsIn and urlsOut Xml tags.

HttpCompressionAgent also uses Regular Expression values within its web.config HttpCompression configuration section, within the mimeTypes, urls, assemblies and urlReferrers Xml tags.

To shortcut the process of browsing the Internet, so one can determine how to HTML encode and properly allow for Regular Expression special characters, I have written a basic web transaction which will transform an input Regular Expression string.   Click HERE to try the Regular Expression transformation web transaction.

Sample output from the Regular Expression Transformation web transaction is included for your benefit below...

Regular Expression Transformation Web Transaction

Vista - How Do I Read .CHM Help Files ?

Don't we just love Vista ?   However, on occasion you may find that you can not view the content of CHM files on Windows Vista. You can see the table of contents but the actual details are not displayed, illustrated as follows:

CHM Navigation Error

This can occur if the file has come from another computer, and the OS now blocks these from running. CHM is not the only file that can be affected.  I have also seen this issue with Javascript files that are used in Vista Gadgets.

Right click on the CHM file and display the file properties. 

You can click the Unblock button and it will allow the single CHM file to be trusted.

In addition, check that the path to the .CHM file doesn't have any # characters in it anywhere. Otherwise, the help viewer gets confused (# means something specific in HTML). If it does, you'll have to move the file somewhere else.

CHM Properties