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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:54:57+00:00 2026-05-13T15:54:57+00:00

could you please advice how to verify in python if provided string correspond to

  • 0

could you please advice how to verify in python if provided string correspond to provided pattern and return result.

For example the provided pattern is following:

< [prefix]-[id]> separated by ‘,’>|< log >”

where prefix is any number of alphabetic characters,
id is only numbers but not exceeding 5 digits,
log is any number of any characters

examples:

  1. proj-123|log message
  2. proj-234, proj-345|log message

I suppose the easiest way is to apply regexp which I didn’t use on python.

Thanks.

  • 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-13T15:54:57+00:00Added an answer on May 13, 2026 at 3:54 pm
    (?:[a-z]+-\d{1,5})(?:, [a-z]+-\d{1,5})*\|.*
    

    it’s not clear what you want to capture, that’s why I use non-capturing groups. If you need only boolean:

    >>> regex = '[a-z]+-\d{1,5}(?:, [a-z]+-\d{1,5})*\|.*'
    >>> re.match(regex, 'proj-234, proj-345|log message') is not None
    True
    

    Of course, the same result can be achieved with the sequence of simple string methods:

    prefs, _, log = subj.partition('|')
    for group in prefs.split(', '):
        pref, _, id5 = group.partition('-')
        if id5.isdigit() and len(id5) <= 5 and pref.isalpha():
             print(pref, id5)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

could you please advice how to output 2012-08-11 in JavaScript as a string without
could you please advice how to track progress of file upload to HTTP Server?
could you please advice how to connect to development machine from device? I can
Could you please advice a Server against which I can test my Class which
Could you please advice me what is more secure way and what procedure to
Please advice: I write here part of JAVA language in args[0] could be capital
Could you please advice me a tutorial or book to do a web site
Could someone please advice why i have a memory leak in this code? I
could you please advice what Java I/O Streams can be used for? Every of
Could you please advice me a plugin or a solution on jquery. I need

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.