Advanced Regex Expressions - Q. 7

Screen Link: Learn data science with Python and R projects

My Code:
pattern = r"\be[-\s]?mail"
titles_clean = titles.str.replace(pattern, “email”, flags=re.I)

What I expected to happen:
When running the code, I expected to get titles that would feature “email” on its names.

What actually happened:
0 Interactive Dynamic Video
1 Florida DJs May Face Felony for April Fools’ W…
2 Technology ventures: From Idea to Enterprise
3 Note by Note: The Making of Steinway L1037 (2007)
4 Title II kills investment? Comcast and other I…

20094 How Purism Avoids Intels Active Management Tec…
20095 YC Application Translated and Broken Down
20096 Microkernels are slow and Elvis didn’t do no d…
20097 How Product Hunt really works
20098 RoboBrowser: Your friendly neighborhood web sc…

None of the answers feature “email” on its name, also some of them are presented incomplete (using “…”).


  1. Is there an option that would allow to see the full titles (without the “…”)?
  2. Why does the answer feature titles that do not feature “email” on its name?
    Examples: Interactive Dynamic Video, Technology ventures: From Idea to Enterprise, How Product Hunt really works

Hi! I know it’s been a while since you posted your question, but I think I will try to help with Q2 in case someone else has the same doubt.

  1. When you run the replace function on the titles what the code does is it goes through every row (title) and if it finds a match for our pattern it will replace it with “email”; if there’s no match it will leave the title unchanged. That’s why when you look into titles_clean you see titles without email (they didn’t have a match).

Hope that helps!