Fix regular expression for memory management