What if your search contains a "?"

HI! I wanted to know something. When we use the series.str.contains() method it is possible to search for “email” or “e-mail” using the code “series.str.contains( “e-?mail” )” where the “’?” symbol means that “-” can be one or two times. My question is, what if our search also requires a “?”, for example. “series.str.contains( “are you there?” )”, would the “?” be interpreted as “e” can be 0 or 1 time?

Hi @cdchavezq, welcome to the community!

In your example, the ? would be interpreted as if the e can be 0 or 1 times. If you want to include the question mark as a search character, you would need to escape it with \. So "are you there\?" would include the question mark as part of the query.

For more questions like this, I would highly recommend playing around with the Regexr tool. You can put any text you like and play with different search combinations and see what does and doesn’t work. It’s a great testing ground for “what if” scenarios!

Thank you SO MUCH ! I appreciate your immediate help :smile: