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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -