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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:43:43+00:00 2026-05-28T13:43:43+00:00

I have written a python script (my very first) that accepts input of a

  • 0

I have written a python script (my very first) that accepts input of a string and then uses re.search to create groups from the string for later use.

The input string would like something like this:

NSC_sdiakjfean=ffffffff3c19594d45525d5f4f58455e445a4a423660

The re.search I’m currently using is:

s = re.search('NSC_([a-zA-Z0-9\-\_\.]*)=[0-9a-f]{8}([0-9a-f]{8})[0-9a-f]{24}([0-9a-f]{4})',name)

The problem that I’ve found is that sometimes the input I want to use is missing this section [0-9a-f]{24} so my python script crashes with an exception and doesn’t capture the last group.

Is there any regex (yes I’ve googled this lots) that I can use for the last group start at the end of the input string and just group the last 4 digits?

Thanks in advance.

Adam

  • 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-28T13:43:44+00:00Added an answer on May 28, 2026 at 1:43 pm

    $ matches the end of the string.

    >>> import re
    >>> re.search("1234$","lkjlkj1234") # matches
    <_sre.SRE_Match object at 0x6a10578>
    >>> re.search("1234$","lkjlkj1234ff") # does not match
    >>>
    

    So the expression you may want is

    s = re.search('([0-9a-f]{4})$',name)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written up a python script that allows a user to input a
I have a mechanize script written in python that fills out a web form
I have written a Django app that makes use of Python threading to create
Greetings. I have written a little python script that calls MySQL in a subprocess.
I have an installation script written in Python (in Linux) that runs as root
I have written a Python script that checks a certain e-mail address and passes
I have written a Python script that currently is designed to handle traditional CGI
I have written a short python script that opens Google music in web view
I am new to python and i have written a script that converts a
I have written a python script which watches a directory for new subdirectories, and

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.