Reputation: 704
i have a string in which a word is like this "#<i><b>when</b></i>"
. i want only word without any tag. when in striped "#"
word became "<i><b>when</b></i>"
. but when i striped "<i>"
word became like "b>when"<b>when</b>"?
Upvotes: 0
Views: 117
Reputation: 2042
Use regular expressions.
>>> import re
>>> s='#<i><b>when</b></i>'
>>> wordPattern = re.compile(r'\>(\w+)\<')
>>> wordPattern.search(s).groups()
('when',)
Upvotes: 0
Reputation: 799082
Slice it.
>>> '#<i><b>when</b></i>'[4:-4]
'<b>when</b>'
Upvotes: 1