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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:00:36+00:00 2026-06-03T03:00:36+00:00

list1 = [‘Contact: Hamdan Z Hamdan, MBBS, Msc’, ‘\r\n ‘, ‘+249912468264’, ‘\r\n ‘, ‘hamdanology@hotmail.com’,

  • 0
list1 = ['Contact: Hamdan Z Hamdan, MBBS, Msc',
        '\r\n            ',
        '+249912468264',
        '\r\n                  ',
        'hamdanology@hotmail.com',
        '\r\n                ',
        'Contact: Maha I Mohammed, MBBS, PhD',
        '\r\n            ',
        '+249912230895',
        '\r\n                  ',
        '\r\n                ',
        'Sudan',
        'Jaber abo aliz',
        '\r\n                  ',
        'Recruiting',
        '\r\n          ',
        'Khartoum, Sudan, 1111  ',
        u'Contact: Khaled H Bakheet, MD,PhD \xa0 \xa0 +249912957764 \xa0 \xa0 ',
        'khalid2_3456@yahoo.com',
        u' \xa0 \xa0 ',
        u'Principal Investigator: Hamdan Z Hamdan, MBBS,MSc \xa0 \xa0  \xa0 \xa0  \xa0 \xa0 ',
       'Principal Investigator:',
       '\r\n      ',
       'Hamdan Z Hamdan, MBBS, MSc',
       '\r\n            ',
        'Al-Neelain University',
        '\r\n                '
    ]

From this list of strings I need to extract only 4 digit integers which should not be associated with other characters?

Example: ‘1111’ only is the needed output.

How we should write the regex in python? Obviously, this won’t work: *([\d]{4})*.

  • 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-03T03:00:37+00:00Added an answer on June 3, 2026 at 3:00 am

    You can use \b in a regular expression to indicate a word boundary, so the following will work for you:

    import re
    
    for s in list1:
        m = re.search(r'\b\d{4}\b', s)
        if m:
            print m.group(0)
    

    … which just outputs 1111. The documentation for \b explains further:

    \b

    Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of alphanumeric or underscore characters, so the end of a word is indicated by whitespace or a non-alphanumeric, non-underscore character. […]

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

Sidebar

Related Questions

list1 == list2 To do the above check, will Scala iterate through both lists
List1 in the following example is a SortedList(Of MyClass) and contains 251 members. The
I have two lists (list1 and list2) containing references to some objects, where some
Suppose I have three lists: list1 = a, c, d, r, t list2 =
final=cacls + E:/ + \ + list1[2] + + list1[3] + \ + /p
I have a ListView in main.xml where android:entries=@array/list1 and I'd like to update that
Private Sub Command1_Click() Dim x As Integer For x = 1 To 100 List1.AddItem
I got a function like def f(): ... ... return [list1, list2] this returns
Is there a way to find if a list contains duplicates. For example: list1
def common_elements(list1, list2): Return a list containing the elements which are in both list1

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.