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

238
Views
Regex on picking S3 bucket name from S3 URI

I have been trying to regex pattern to obtain S3 bucket name from S3 URI but have no luck.

example: s3://example-bucket/file-name.filetype

Closest I could get with this: \/\/([^\/].*[^\/])\/ but i'm not sure how to negate the slash from the result

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The part ([^/]+) is looking for a sequence of of characters that are not slash. keeping close with what you had you could write //([^/]+)/ but this is the same as

//([^/]+)

optional you could use lookbehind (?<=//) and/or lookahead (?=/)

(?<=//)([^/]+)(?=/)

(depending on your use cases a couple of different lookahead expressions are possible)

'lookaround' especially 'lookbehind' is not supported in all regexp dialects. e.g. not in JavaScript

Debuggex Demo

about 4 years ago · Santiago Trujillo Report

0

If you don't have the lookbehind option (javascript regex), and your URL structure is consistent enough, then perhaps this pattern will be useful:

[^\/]+(?=\/[^\/])

In English: "match one or more non-forward slashes, followed (but not actually matched, via the lookahead) by one forward slash and a non-forward slash".

(your other option would be to access your match groups in order to get rid of the slashes that you matched)

https://regex101.com/r/XM05Sw/2/

about 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!