You could use the following regular expression:
import re
text = "fieldnameRelated_actions/fieldnamedatatypeRESOURCE_LIST![CDATA[nprod00123456]/value>value>![CDATA[nprod00765432]]/valuevaluesfield"
print re.findall(r'(nprod\d+)', text)
Giving you:
['nprod00123456', 'nprod00765432']
This works by finding any nprod
in the text followed by one or more digits.
Alternatively, without re
, it might be possible as follows:
print ['nprod{}'.format(t.split(']')[0]) for t in text.split('nprod')[1:]]
1
solved How to print a work in string containing specific characters [closed]