我試圖使用Python正則表達式包重新匹配在python 2.7以下字符串時遇到未來與該正則表達式的代碼麻煩:Python的RE(正則表達式)匹配包含字母,連字符,數字特定字符串
https://www.this.com/john-smith/e5609239
https://www.this.com/jane-johnson/e426609216
https://www.this.com/wendy-saad/e172645609215
https://www.this.com/nick-madison/e7265609214
https://www.this.com/tom-taylor/e17265709211
https://www.this.com/james-bates/e9212
所以前綴是固定的「https://www.this.com/」,然後有一個可變數量的小寫字母,然後是「 - 」,然後是「e」,然後是可變數量的數字。
這是我試圖無濟於事:
href=re.compile("https://www.this.com/people-search/[a-z]+[\-](?P<firstNumBlock>\d+)/")
href=re.compile("https://www.this.com/people-search/[a-z][\-][a-z]+/e[0-9]+")
感謝您的幫助!