# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(?!\d\s\bPP\b)(?!\d\s\bpp\b)(?!\d\s\bGa\b)(?!\d\s\bMa\b)(?=\d\s\w)"
test_str = "1 Abdullaev, R.N.. Akhmedzhanov. M.A. and Borisov, O.M., 1972, Occurrence of oncolites in the Precambrian of northern Nuratau. Uzb. Geol. Zh.. 1972 (1): 111 (in Russian). 2 Abelson, P.H.. 1967. Conversion of biochemicals to kerogen and n-paraffins. In: P.H. Abelson (Editor). Researches in Geochemistry, 2. Wiley. New York. N.Y.. pp. 63-86. 3 Abelson. P.H. and Hare, P.E.. 1969. Recent amino acids in the Gunflint chert. Carnegie Inst. Wash , Yearb.. 67: 208-210. 4 Abelson. P.H. and Hare, P.E., 1970. Uptake of amino acids by kerogen. Carnegie Inst. Wash.. Yearb., 68: 297-303. 5 Abelson, P.H. and Hare, P.E.. 1971. Reactions of amino acids with natural and artificial humus and kerogens. Carnegie Inst. Wash., Yearb.. 69: 327-334. 6 Abelson, P.H. and Hoering. T.C.. 1961. Carbon isotope fractionation in formation of amino acids. Proc. Natl. Acad. Sci. US.. 47: 623-632. 7 Ablizin. B.D.. Kurbatskiy. A.M. and Krylov, I.N., 1969. Upper Precambrian stratigraphy in the north Urals western sector. Izu. Akad. Nauk S.S.S.R., Ser. Geol., 1969 (9): 108-113 (in Russian). 8 Achauer, C.W.. 1967. Petrography of a reef complex in Lower Cretaceous James Limestone. Bull. Am. Assoc. Pet. Geol., 51: 452 (abstract). 9 Achauer. C.W. and Johnson, J.H., 1969. Algal strornatolites in the James Reef Complex (Lower Cretaceous). Fairway Field, Texas. J. S e dim e nt. P et r ol.. 39: 1466. 10 Ackman, R.G.. Tocher, C.S. and McLachlan. J.. 1968. Marine phytoplankter fatty acids. J. Fish. Res. Board Can., 25: 1603-1620. 11 Adolphe. J.-P.. 1970. Etude comparde des calcins en choux fleurs du Moyen Nord Canadien, de France et du Liban. C.R. Acad. Sci., Paris, 270: 1080-1083. 12 Adolphe, J.-P., 1973. The carbonate encrustations of the Pont du Gard Aqueduct, France. C.R. Acad. Sci., Paris, Ser. D. 277(21): 2329-2332 (in French). 1341 Adolphe, J.-P. and Rofes, G.. 1973. Calcareous concretions from the Levri6re. a tributary of the Epte River, subtributary of the Seine. Assoc. Fr. Etud. Quaternaire. Bull.. lO(35): 79-87 (in French). 14 Ahr, W.M.. 1967. Origin and Paleoenvironment of some Cambrian Algal Reefs, Mason County Area, Texas. Thesis, Rice University, Houston, Texas, 104 PP. (UNv. Microfilms, Ann Arbor. 67-13.049.) 15 Ahr. W.M.. 1969. Paleoenvironment. algal structures. and fossil algae in Upper Cambrian of central Texas. Bull. Am. Assoc. P et. G e ol.. 53(3): 703 (Abstract)."
subst = ""
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html