Check that the “attributes” exists before running a regular expression (could fail if attributes were undefined).