Searching for text patterns
Within a given source file, pattern-based scanning searches for text patterns in files by extension, allowing the search to exist in source files, XML configuration files, and other text files.
For example, you might want to create a pattern search to ensure
that improper email addresses are not hardcoded into your application.
In this case, if you want to make sure that the application does not
use corporate email addresses, you could search for a pattern such
as .*@mycompany.com
.
Examples
This pattern finds | Pattern |
---|---|
An email address | [A-Za-z]\.[A-Za-z]@[A-Za-z][A-Za-]\.com |
All instances of the pattern, such as passWord = |
[Pp][Aa][Ss][Ss][Ww][Oo][Rr][Dd]\W*= |
Any instance of the MD5 hashing algorithm | getInstance[[:space:]]*\([[:space:]]*"MD5 |