Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:13:58+00:00 2026-06-12T17:13:58+00:00

i want to give regex a pattern and force it to read it all

  • 0

i want to give regex a pattern and force it to read it all ..

http://example.com/w/2/1/x/some-12345_x.png

i want to target “some-12345_x”
i used this /\/(.*).png/, it doesnt work for some reason

how do i force it to remember it must start with / and end with .png?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:13:59+00:00Added an answer on June 12, 2026 at 5:13 pm

    If you always want to get the final file-name, minus the extension, you could use PHP’s substr() instead of trying to come up with a regex:

    $lastSlash = strrpos($url, '/') + 1;
    $name = substr($url, $lastSlash, strrpos($url, '.') - $lastSlash);
    

    Also, a more readable method would be to use PHP’s basename():

    $filename = basename($url);
    $name = substr($filename, 0, strpos($filename, '.'));
    

    To actually use a regex, you could use the following pattern:

    .*/([^.]+).png$
    

    To use this with PHP’s preg_match():

    preg_match('|.*/([^.]+).png$|', $url, $matches);
    $name = $matches[1];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need Some Help With Regex: I want to replace [url=http://youtube.com]YouTube.com[/url] with <a href=http://youtube.com>YouTube.com</a> the
i want to write a regex that will give me all chars that are
I'm don't know regex really well, so can someone give me example how to
I have some strings to check against a Regex pattern. Here is the regex:
Command should do: Give 1 as output if the pattern *@he.com is on the
I'm using the following tester to try and figure out this regex: http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx My
I have a string 2045111780&&-3&5&-7 I want a regex to give me groups as:
how can i create a preg_match_all regex pattern for php to give me this
I want to give an alert after person sign up successfully. And then I
I want to give an object an attribute once a transition is finished. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.