Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Regex to match s3 link

I have a s3 object in the following format.

https://s3-{region}.amazonaws.com/{bucket}/{environment}/{keyname}

I need a regex which can fetch me the individual variables from a s3 link. Currently I have the following regex.

r"https\:\/\/s3\-(\w+)\.amazonaws\.com\/(\w+)\/(\w+)\/(\w+)$"

But it returns None.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You could go for:

https?://s3-
(?P<region>[^.]+).amazonaws.com/
(?P<bucket>[^/]+)/
(?P<environment>[^/]+)/
(?P<keyname>.*)

See a demo on regex101.com.


In Python this would be:

import re

rx = re.compile(r'''
    https?://s3-
    (?P<region>[^.]+).amazonaws.com/
    (?P<bucket>[^/]+)/
    (?P<environment>[^/]+)/
    (?P<keyname>.*)''', re.VERBOSE)

links = rx.findall(your_string_here)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!