Tried to pull off some crazy regexes to make this work but it didn't work reliably. Any idea?