fixed nullpointerexception error and implemented regex functionality
minor