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 8693565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:34:22+00:00 2026-06-13T00:34:22+00:00

In my program, the user should be able to specify a naming scheme. The

  • 0

In my program, the user should be able to specify a naming scheme. The naming scheme they specify should contain a simple date format like “yyyyMMdd”, “MM-dd-yyyy”, “yyyy/MM/dd”, etc. I would prefer the order of the day, month, and year to not matter but can require a certain ordering (like year comes first followed by month followed by day). I would like to be able to easily retrieve this date out of the string in order to use it with the SimpleDateFormat class.

Here are some examples:

input string:    "abc?>@dyyyy-MM-dd-|(s*&d)"
output string:   "yyyy-MM-dd"

input string:    "daddy-MM/dd/yyyy-moMMy"
output string:   "MM/dd/yyyy"

Ultimately what I want to do is to replace (in the string the user provides) the date format specified with the current date.

If I wanted to fix it so the user can only enter year followed by month followed by day then I can do something like this:

String dateFormat = name.substring(name.indexOf("yyyy"), name.indexOf("dd") + 2)

but this means the user cannot use the String sequences “yyyy” and “dd” in the rest of the String or else this method would not work. This expression can also be represented by a regex but I dont know how to easily pull a substring that matches a regex out of a string.

  • 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-13T00:34:24+00:00Added an answer on June 13, 2026 at 12:34 am

    Use regex pattern

    (MM|dd|yyyy)[\\/-]?(?!\\1)(MM|dd|yyyy)[\\/-]?(?!\\1)(?!\\2)(MM|dd|yyyy)
    

    You might want to add some other separators you want to allow into [...] sections of the above pattern.

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

Sidebar

Related Questions

What the program should do: After the user clicks the delete button with a
If a user types in [[0,0,0], [0,0,1], [1,1,0]] and press enter, the program should
The following program expects user input in the mixed fraction format 'whole_numbernumerator/denominator' and assigns
I need to write a simple terminal-based program that should, Read some text from
I have to make a java program that when user enters 0 it should
I'm trying to create a program in C# that should be able to create,
I need to design a Task Scheduler Where 1) User should be able to
I am coding an invoicing application. The user should be able to add a
My program takes user name and password authentication from user before initialising the program,
I have the following program flow: User fills in form My app generates 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.