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 8726031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:10:13+00:00 2026-06-13T08:10:13+00:00

I am trying to determine if a string matches a regular expression pattern: expected

  • 0

I am trying to determine if a string matches a regular expression pattern:

expected = re.compile(r'session \d+: running')
string = "session 1234567890: running"
re.match(expected, string)

However, re.match() always returns None. Am I trying to match the decimals incorrectly? The number should be 10 digits but I would like to cover the case that it is more or less digits.

EDIT: The string parameter is actually a result of a previous match:

expected = re.compile(r'session \d+: running')
found = re.match(otherRegex, otherString)
re.match(expected, found.groups()[0])

When I print the type of found.groups()[0] it prints class str and when I print found.groups()[0], it prints the string I expect: "session 1234567890: running". Could this be why it is not working for me?

  • 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-06-13T08:10:14+00:00Added an answer on June 13, 2026 at 8:10 am

    In my question I had shortened the string to the parts that were relevant. The actual string had:

    expected = re.compile(r'session \d+: running task(s)')
    str = "session 1234567890: running(s)"
    re.match(expected, str)
    

    The reason there were never matches is because the '(' and ')' characters are special characters and I needed to escape them. The code is now:

    expected = re.compile(r'session \d+: running task\(s\)')
    str= "session 1234567890: running(s)"
    re.match(expected, str)
    

    Sorry for the confusion

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

Sidebar

Related Questions

I'm trying to determine the regular expression to verify that a string has at
I have been trying to create a regular expressions pattern that matches any reference
I am trying to create a regular expression that determines if a string (of
I'm trying to determine the width of a string. I'm using the following code
I am trying to write a function to determine if a string is a
I am trying to use regular expressions to determine what format the user have
I'm trying to do a match in regex. It must match a string of
I'm trying to determine if a String represents a Double . I expect the
I am trying to determine whether a string input by a user is valid
I'm trying to determine the user agent string for surface RT for testing purposes.

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.