How to filter string with condition using python -
i have string
s ='jacky chan || ceo ||managing director , general partner, b robotics || san francisco bay area'
how can filter out "he ceo" part based on keyword "ceo" within string using python?
output: 'jacky chan||managing director , general partner, b robotics || san francisco bay area'
if split string using delimiter ||
, can inspect each split , include in our new string if does not contain string 'ceo'
.
'||'.join(substr substr in s.split('||') if 'ceo' not in substr)
Comments
Post a Comment