The imidazolium-pyrene self-assembling nanoprobes can rapidly discriminate four types of surfactants. The surfactants disassembled the probes to turn on significant fluorescence and transform between a pyrene monomer and an excimer, generating a two-dimensional analysis map. The probes were further used to identify different bacterial species.