Linear and efficient string matching algorithms based on weak factor recognition