# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"src=\"(\S+)?\".+\s.+\s.+href=(\S+).+ember-view\">\s+(\S+)?(?:\s(\S+))\s(\S+)\s+.+\s+.+\s.+\s\S+\s.+\s.+clamp__line.+?(?=>)\W(\s+.+(?=<!)|.+(?=<\/span>))"
test_str = ("<section id=\"ember381\" class=\"artdeco-card artdeco-card--with-hover ember-view\"><!---->\n"
" <div class=\"org-people-profile-card__profile-info\">\n"
"<artdeco-entity-lockup stacked=\"center\" size=\"5\" id=\"ember382\" class=\"artdeco-entity-lockup--stacked-center artdeco-entity-lockup--size-5 artdeco-entity-lockup ember-view\"><artdeco-entity-lockup-image id=\"ember383\" class=\"artdeco-entity-lockup__image artdeco-entity-lockup__image--type-circle ember-view\" type=\"circle\"><a data-control-name=\"people_profile_card_image_link\" href=\"/in/omar-bakali-85464741/\" id=\"ember384\" class=\"ember-view\"> <img class=\"lazy-image loaded\" alt=\"Omar’s profile picture\" src=\"https://media.licdn.com/dms/image/C4D03AQFLLRD0oaAAPw/profile-displayphoto-shrink_100_100/0?e=1565827200&v=beta&t=1FUl_3ALdjwdoHj0Oqq1lt5Es-0SPekm1zt-G_iVH3g\" width=\"72\" height=\"72\">\n"
"</a>\n"
"</artdeco-entity-lockup-image><artdeco-entity-lockup-content id=\"ember385\" class=\"artdeco-entity-lockup__content ember-view\"><artdeco-entity-lockup-title id=\"ember386\" class=\"artdeco-entity-lockup__title ember-view\"><a data-control-name=\"people_profile_card_name_link\" href=\"/in/omar-bakali-85464741/\" id=\"ember387\" class=\"link-without-visited-state ember-view\"> <div id=\"ember389\" class=\"org-people-profile-card__profile-title t-black lt-line-clamp lt-line-clamp--single-line ember-view\"> Omar Bakali\n\n"
"<!----></div>\n\n"
"</a> \n"
"</artdeco-entity-lockup-title> <artdeco-entity-lockup-badge id=\"ember390\" class=\"artdeco-entity-lockup__badge ember-view\"> <span class=\"artdeco-entity-lockup__degree \">· 1st</span>\n"
"<!----><!----></artdeco-entity-lockup-badge>\n"
"<artdeco-entity-lockup-subtitle id=\"ember391\" class=\"artdeco-entity-lockup__subtitle ember-view\"> <div class=\"t-14 t-black--light t-normal\">\n"
" <div id=\"ember393\" class=\"ember-view\"> <span class=\"lt-line-clamp__line lt-line-clamp__line--last\">\n"
" Founder & CEO @ Ayni Widny<!----></span>\n\n"
"<!----><span class=\"lt-line-clamp__ellipsis lt-line-clamp__ellipsis--dummy\">...</span></div>\n\n"
" </div>\n"
"</artdeco-entity-lockup-subtitle><artdeco-entity-lockup-caption id=\"ember394\" class=\"artdeco-entity-lockup__caption ember-view\"> <div class=\"truncate\">\n"
" ’14 Management\n"
" </div>\n"
"</artdeco-entity-lockup-caption></artdeco-entity-lockup-content>\n"
"</artdeco-entity-lockup> <span>\n"
" <img class=\"lazy-image round-image EntityPhoto-circle-1 v-align-middle loaded\" alt=\"lionel’s profile picture\" src=\"https://media.licdn.com/dms/image/C4E03AQH3TWM5bEiO1g/profile-displayphoto-shrink_100_100/0?e=1565827200&v=beta&t=r1QXqaWKGQI3PAbSYD2EKibJLV2LyDNrWLJhiuUPGx8\" width=\"72\" height=\"72\">\n"
" <span class=\"t-12 t-black t-bold\">\n"
" 26 shared connections\n"
" </span>\n"
" </span>\n"
" </div>\n\n"
" <footer class=\"artdeco-card__actions\">\n"
"<a data-control-name=\"people_profile_card_message_link\" target=\"_blank\" href=\"/messaging/compose/?connId=ACoAAAjQ0AABtNb896iwtKva5joQFIxDhxGBfAQ\" id=\"ember395\" class=\"artdeco-button artdeco-button--tertiary artdeco-button--fluid artdeco-button--3 ember-view\"> <span class=\"artdeco-button__text\">\n"
" Message\n"
" </span>\n"
"</a> </footer>\n"
"</section>\n\n"
"<section id=\"ember364\" class=\"artdeco-card artdeco-card--with-hover ember-view\"><!---->\n"
" <div class=\"org-people-profile-card__profile-info\">\n"
"<artdeco-entity-lockup stacked=\"center\" size=\"5\" id=\"ember365\" class=\"artdeco-entity-lockup--stacked-center artdeco-entity-lockup--size-5 artdeco-entity-lockup ember-view\"><artdeco-entity-lockup-image id=\"ember366\" class=\"artdeco-entity-lockup__image artdeco-entity-lockup__image--type-circle ember-view\" type=\"circle\"><a data-control-name=\"people_profile_card_image_link\" href=\"/in/clementinenannan/\" id=\"ember367\" class=\"ember-view\"> <img class=\"lazy-image loaded\" alt=\"Clémentine’s profile picture\" src=\"https://media.licdn.com/dms/image/C5603AQHR1X88QCWsnw/profile-displayphoto-shrink_100_100/0?e=1565827200&v=beta&t=fwXOyrczSApTvcE6A1gP-QZLIVMJ79A6L0d1dwdQ5CU\" width=\"72\" height=\"72\">\n"
"</a>\n"
"</artdeco-entity-lockup-image><artdeco-entity-lockup-content id=\"ember368\" class=\"artdeco-entity-lockup__content ember-view\"><artdeco-entity-lockup-title id=\"ember369\" class=\"artdeco-entity-lockup__title ember-view\"><a data-control-name=\"people_profile_card_name_link\" href=\"/in/clementinenannan/\" id=\"ember370\" class=\"link-without-visited-state ember-view\"> <div id=\"ember372\" class=\"org-people-profile-card__profile-title t-black lt-line-clamp lt-line-clamp--single-line ember-view\"> Clémentine lucie Nannan\n\n"
"<!----></div>\n\n"
"</a> \n"
"</artdeco-entity-lockup-title> <artdeco-entity-lockup-badge id=\"ember373\" class=\"artdeco-entity-lockup__badge ember-view\"> <span class=\"artdeco-entity-lockup__degree \">· 1st</span>\n"
"<!----><!----></artdeco-entity-lockup-badge>\n"
"<artdeco-entity-lockup-subtitle id=\"ember374\" class=\"artdeco-entity-lockup__subtitle ember-view\"> <div class=\"t-14 t-black--light t-normal\">\n"
" <div id=\"ember376\" class=\"ember-view\"> <span class=\"lt-line-clamp__line\">Marketing Management and</span>\n"
" <span class=\"lt-line-clamp__line lt-line-clamp__line--last\">\n"
" Digital student at ESSEC - F<span class=\"lt-line-clamp__ellipsis\">...\n"
"<!----> </span></span>\n\n"
"<!----><span class=\"lt-line-clamp__ellipsis lt-line-clamp__ellipsis--dummy\">...</span></div>\n\n"
" </div>\n"
"</artdeco-entity-lockup-subtitle><artdeco-entity-lockup-caption id=\"ember377\" class=\"artdeco-entity-lockup__caption ember-view\"> <div class=\"truncate\">\n"
" ’18 Marketing\n"
" </div>\n"
"</artdeco-entity-lockup-caption></artdeco-entity-lockup-content>\n"
"</artdeco-entity-lockup> <span>\n"
" <img class=\"lazy-image round-image EntityPhoto-circle-1 v-align-middle loaded\" alt=\"Vincent’s profile picture\" src=\"https://media.licdn.com/dms/image/C4D03AQFq5VjBd4AgZQ/profile-displayphoto-shrink_100_100/0?e=1565827200&v=beta&t=Tt7tGo5BV12fhDTa0mMvj91f0WsArricQ0WpZXjSbKQ\" width=\"72\" height=\"72\">\n"
" <span class=\"t-12 t-black t-bold\">\n"
" 24 shared connections\n"
" </span>\n"
" </span>\n"
" </div>\n\n"
" <footer class=\"artdeco-card__actions\">\n"
"<a data-control-name=\"people_profile_card_message_link\" target=\"_blank\" href=\"/messaging/compose/?connId=ACoAABMxF04BkeFqBF-OCOXN4MA1lD7R14Fw4zQ\" id=\"ember378\" class=\"artdeco-button artdeco-button--tertiary artdeco-button--fluid artdeco-button--3 ember-view\"> <span class=\"artdeco-button__text\">\n"
" Message\n"
" </span>\n"
"</a> </footer>\n"
"</section>")
matches = re.finditer(regex, test_str, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
print ("Match {matchNum} was found at {start}-{end}: {match}".format(matchNum = matchNum, start = match.start(), end = match.end(), match = match.group()))
for groupNum in range(0, len(match.groups())):
groupNum = groupNum + 1
print ("Group {groupNum} found at {start}-{end}: {group}".format(groupNum = groupNum, start = match.start(groupNum), end = match.end(groupNum), group = match.group(groupNum)))
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html