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

  • Home
  • SEARCH
  • 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 7583253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:38:01+00:00 2026-05-30T18:38:01+00:00

In a Python match pattern, how do I match a literal digit like 1

  • 0

In a Python match pattern, how do I match a literal digit like 1 after a backreference by number like \1?

I tried the \g<1> syntax that is available in substitution patterns for this purpose, but it doesn’t work in my match pattern.

I have a larger problem that I want to solve using a function that will perform the following somewhat unusual task. The task is to construct patterns dynamically so that each pattern will match digit sequences that have repeated digits in certain positions and specific digits in the remaining positions.

  • 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-30T18:38:02+00:00Added an answer on May 30, 2026 at 6:38 pm

    I noticed that I don’t need the \g<1> syntax. Instead I can use one of several techniques to separate the numeric backreference like \2 from the digit like 9 that follows it. Here are three such techniques:

    • a non-capturing group (?:\2)9
    • an otherwise unnecessary quantification by one \2{1}9
    • using an otherwise unnecessary character class to contain only the digit that follows the backreference \2[9]
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to create a regular expression in Python that will match against a
I'd like to match the contents within each paragraph in html using a python
I'm trying to write a python regular expression that will match both these URLs:
In my python code i want to pattern match a string for atleast two
I'm writing grepath utility that finds executables in %PATH% that match a pattern. I
I am trying to match a data URI pattern of data:\w+/\w+;\w+,\w+ in Python. How
In Python compiled regex patterns have a findall method that does the following: Return
I am very new to python and I want to match a pattern which
I'm trying to match on a line ending with something like: blocking=12345us The pattern
I am trying to match a pattern like so: Pattern : (abc)(def)(ghi)h Match :

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.