Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6639179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:31:25+00:00 2026-05-25T23:31:25+00:00

I am trying to substring search >>>str1 = ‘this’ >>>str2 = ‘researching this’ >>>str3

  • 0

I am trying to substring search

>>>str1 = 'this'
>>>str2 = 'researching this'
>>>str3 = 'researching this '

>>>"[^a-z]"+str1+"[^a-z]" in str2
False

>>>"[^a-z]"+str1+"[^a-z]" in str3
False

I wanted to True when looking in str3. what am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:31:26+00:00Added an answer on May 25, 2026 at 11:31 pm

    You want Python’s re module:

    >>> import re
    >>> regex = re.compile(r"\sthis\s") # \s is whitespace
    >>> # OR
    >>> regex = re.compile(r"\Wthis\W")
    >>> # \w is a word character ([a-zA-Z0-9_]), \W is anything but a word character
    >>> str2 = 'researching this'
    >>> str3 = 'researching this '
    >>> bool(regex.search(str2))
    False
    >>> regex.search(str3)
    <_sre.SRE_Match object at 0x10044e8b8>
    >>> bool(regex.search(str3))
    True
    

    I have a hunch you’re actually looking for the word “this”, not “this” with non-word characters around it. In that case, you should be using the word boundary escape sequence \b.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to do a substring search from an access 2010 database in
I am trying to search for the substring abc in a specific file in
A substring of my XML looks like this: <foo value1=a value2=b>value3</foo> I'm trying to
How can I replace it? I've been trying this: string.replaceFirst(substring, ); but it's not
I guess I'm getting this error because the string is trying to substring a
I have a problem where I am trying to search for a substring in
Trying to get my css / C# functions to look like this: body {
Trying to keep all the presentation stuff in the xhtml on this project and
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I'm trying to write a suggestion search box and I cannot find a solution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.