import re text = 'this is a text' try: found = re.search('is(.+?)text', text).group(1) except AttributeError: # AAA, ZZZ not found in the original string found = '0 wtitle' # apply your error handling found => a # To get more than 1 search job_title = [] for i in range(0,9282): text = data.work_experiences.iloc[i] try: title = re.findall(r"wtitle (.*?) wcompany",text) except : title = 'onejob' job_title.append(title) data['job_title'] = job_title
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter