Wednesday, July 7, 2010

Regex Samples

// Filter images file name
var regExp = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF|.png|.PNG|.bmp|.BMP)$/;


// Check number format in integer and float, the symbol +, - or
// thousandsprate like(123,456,78.001) is no acceptable.
^((((\d+(\.)?)|(\d*\.\d+))(\d+)?))$


// Check XSS Meta-characters insid the input string. This 
// characters and string in the pattern is forbidden in input string.
[\r\n\\'"<>&\u0085]|(?i:\bjavascript|jscript)