Regex searching and some refactoring
updated regex matching to be case-insensitive