Question

Using python to filter and extract a value

  • 3 August 2023
  • 3 replies
  • 88 views

Hi, i am using filters to extract words after the word “from” in an email SUBJECT line. The python I am using is not working...does anyone know python well and able to help?

 

Here’s what I am using

 

import re

text = "Import data from file.txt"
match = re.search(r'from\s+(\w+)', text, re.IGNORECASE)

if match:
    captured_word = match.group(1)
    print(captured_word)
else:
    print("No match found")

 

Thanks ahead of time for your help!


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

i tried this too:

 

import re

subject_line = "Re: Important Update from Marketing Team"

match = re.search(r'from\s+(.+)', subject_line, re.IGNORECASE)

if match:
    captured_text = match.group(1)
    print(captured_text)
else:
    print("No match found")

 

Userlevel 7
Badge +14

Hi @JLBroder 

Good question.

Perhaps you can outline a specific example of what you are trying to achieve with the data inputs and data outputs, regardless of the Python Code.

Screenshots are helpful.

i ended up just using the text separator function and was able to achieve it. thanks!