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

  • SEARCH
  • Home
  • 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 6727335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:02:16+00:00 2026-05-26T10:02:16+00:00

I am just a noob on reg exp and I am trying to learn

  • 0

I am just a noob on reg exp and I am trying to learn them. If I have a file name like this:

myfile(1).jpg or myfile(21).jpg

How can I extract with an reg exp (php or javascript) the file name [myfile], bracket numbering [1] and extension [jpg]?

  • 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-05-26T10:02:16+00:00Added an answer on May 26, 2026 at 10:02 am

    Try this regex:

    /^(.*?)(?:\((\d+)\))?\.(.+)$/
    

    $1 variable will contain the filename.
    $2 variable will contain the numbering (if it is available or else it will be undefined or null).
    $3 variable will contain the extension.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this is a very noob question.. but I just can't get
Just a noob trying to learn, I came out with a problem that when
Sorry, this might be a basic/stupid/noob question - I am just trying to tweak
I guess this is just a simple question (I’m such a noob…) I have
This is a very noob question. I'm basically just trying to run the hello
I've just started programming, therefore I'm kinda noob. I'm trying to use python to
I am a complete Noob when it comes to GIT. I have been just
Just learning the world of jquery, and all my googling gives examples like this:
I am just a noob in C#, and I've got this question to ask
I'm a real noob who just started learning 3d programming and i have a

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.