A regular expression question

Cpcp Cp cpxuvs at gmail.com
Thu Sep 29 00:47:44 EDT 2016


Look this

>>> import re
>>> text="asdfnbd]"
>>> m=re.sub("n*?","?",text)
>>> print m
?a?s?d?f?n?b?d?]?

I don't understand the 'non-greedy' pattern.

I think the repl argument should replaces every char in text and outputs "????????".




More information about the Python-list mailing list