This is a follow-up to Abbreviate resolved abbreviations in authors' first names in biblatex, where @PLK provided an answer in which brackets [] and characters between them are replaced by a dot .
One problem here is that I have entries in my .bib file that are anonymous publications, yet we know who the author is. In those cases I fill in the entire name within brackets, as in [John Lennon] below. In such cases where the entire name is between brackets, no replacement with a dot . should take place.
Question: Is there a way to replace brackets with intervening characters with a dot except when the entire author field contains such a sequence (e.g. author = J[ohn] Lennon is replaced by author = J. Lennon, but author = [John Lennon] remains author = [John Lennon]?
Or put differently, can I somehow "protect" the entry author = [John Lennon] below from being targeted by the DeclareSourcemap command?
\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}
\DeclareSourcemap{\maps[datatype = bibtex]{\map{\step[fieldsource = author, match = \regexp{\[[^]]+\]}, replace = .]}}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1970,
AUTHOR = "J[ohn] Lennon",
TITLE = "My life with the Beatles",
YEAR = "1970",
SORTNAME = "John Lennon"}
@BOOK{lennon1971,
AUTHOR = "[John Lennon]",
TITLE = "Moving on",
YEAR = "1971",
SORTNAME = "John Lennon"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

The question Brackets in biblatex entries might also be relevant here.

bibergives errors for me (and doesn't generate output) on your original but.\[[^]]+\]wouldn't match a field that only had[at the start. – David Carlisle Nov 17 '14 at 19:38author = "{John} {Lennon}"? – Werner Nov 17 '14 at 19:51pdflatex + biberin texlive 2014. Also, using\regexp{.\[[^]]+\]}will reduce the former outputLennon, J.toLennon, .. – Sverre Nov 17 '14 at 20:52author = "John Lennon"? It won't, in other words, indicate in the output that I have supplied the name myself. The output should read[Lennon, John], notLennon, John. – Sverre Nov 17 '14 at 20:54author = {[Lennon, John]}? – Werner Nov 17 '14 at 21:09author = "[Lennon, John]". I've also tried"{[Lennon, John]}". They are all replaced by a dot as in the MWE. – Sverre Nov 17 '14 at 21:43