0

I am trying to find the complete Github url from text. But it returns only the first match and not the complete URL. I tested my regex on https://pythex.org/ and its shows the correct match result.

enter image description here

test = 'https://www.github.com/whoisthere'
GITHUB_PATTERN = r"(http(s?):\/\/|[a-zA-Z0-9\-]+\.|[github])[github\/~\-]+\.[a-zA-Z0-9\/~\-_,&=\?\.;]+[^\.,\s<]"
GITHUB_REGEX = re.compile(GITHUB_PATTERN,re.IGNORECASE)
github_regex_result = re.findall(GITHUB_REGEX,test)

if len(github_regex_result) > 0:
    print("GITHUB : {}".format(github_regex_result[0]))
else:
    print(None)

It returns me the following

GITHUB : ('https://', 's')

While I am trying to get the complete url like

GITHUB : ('https://www.github.com/whoisthere')

New screenshot of issue enter image description here

joel
  • 1,156
  • 3
  • 15
  • 42

0 Answers0